The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > AIX
Google UNIX.COM


AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 06-06-2005
Registered User
 

Join Date: Jun 2005
Posts: 2
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
Reply With Quote
Forum Sponsor
  #2  
Old 06-06-2005
Bughunter Extraordinaire
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,262
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
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:33 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0