Friday, June 14, 2013

Cygwin - Setting up environment path in .profile for ksh

ksh provide a .profile file for personalizing your startup environment. Very often, you will use this to setup your personal Unix environment.

In Linux/Unix environment, you can set up environment variables by using export function

export YOUR_ENVIRONMENT_PATH="/root/to/your/path\"

In Windows environment, you will most likely use cygwin as your linux like environment. If you uses cygwin, you should have realized that there is a different on your path format

Windows - C:\Users\XXX
Cygwin - /cygdrive/c/Users/XXX

Thus, you need to handle the conversion of Windows form of path to Unix form of path

In this post, I will provide a .profile setting that setup some cygwin environment variables and start up bash shell with your ksh environment.

Below is the setting in .profile

#Setting up environment path
export YOUR_ENV_PATH="$(cygpath -u "c:\\Users\\XXX")"
#enable your bash environment

cygwin provide a function call cygpath that helps to convert Windows form of path to Unix form of path

cygpath -u "c:\\Users\\XXX" convert "c:\\Users\\XXX" to /cygdrive/c/Users/XXX

Next, please note that your should only change to bash environment after setting up your path

If you enable your bash environment before exporting your path, your environmental path will NOT be set.


No comments:

Post a Comment

PuTTY - Keeping session alive

If you have some VPN tunnels that timeout based on activity, you could try the following setting if you are using PuTTY 1) Open PuTTY and...