![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Setting up variables | solar_ext | UNIX for Dummies Questions & Answers | 3 | 03-28-2008 08:50 AM |
| setting some variables | new2ss | UNIX for Advanced & Expert Users | 7 | 03-16-2008 08:03 PM |
| Setting up Environment Variables | rpandey | Shell Programming and Scripting | 6 | 06-06-2005 06:28 AM |
| cat setting variables | skotapal | Shell Programming and Scripting | 3 | 09-10-2002 06:55 AM |
| setting environment variables ??? | Gargamel | UNIX for Dummies Questions & Answers | 5 | 06-13-2002 08:12 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
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 |
|||
| Google The UNIX and Linux Forums |