Setting Variables not working

Hi all,
I am trying to set up some variables in a shell script. The variables contain values of various paths needed to run a java module. The problem is the variables dont seem to be setting at all.

here is what i am trying to do :

JAR_HOME=/home/was5/bdcms/scheduledjobs/lib
export JAR_HOME

JAVA_HOME=/usr/java131/bin
export JAVA_HOME

SOURCE_HOME=/home/was5/bdcms/scheduledjobs/src
export SOURCE_HOME

CLASS_PATH=.:/home/was5/bdcms/scheduledjobs/src/classes12.jar
export CLASS_PATH

echo $CLASS_PATH

------------END of code -------------

This echo prints the value correctly. Where as if i do the same from unix prompt after executing the script, the variable is always empty. I have tried all kinds of things here(including export CLASS_PATH=value and export SET CLASS_PATH=value among others) and am not able to figure the problem.

Any help or pointers are appreciated.
Thanks

The reason is that the script is executed not in *your* environment, but in an environment of its own. This environment of the script inherits every variable of your environment, but every changes made inside it will be lost upon destruction of this environment - which happens when the script ends.

To execute the script in your own environment use the "." command:

# ./myscript

will execute the script in its own environment, but:

# . ./myscript

will execute it in your environment.

This mechanism is usually used to set up your initial environment. Look at your ~/.profile file and you might eventually notice a line reading ". ~/.kshrc". This is using this mechanism to "source in" (as the correct phrase is) the content of your Korn-shell rc-file to your environment. Usually .kshrc consists of variable declarations, (useful) function definitions, etc.

bakunin