LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to set the environment variables in BASH shell (RHEL) (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-set-the-environment-variables-in-bash-shell-rhel-730602/)

madhusudaniyaar 06-04-2009 04:25 AM

How to set the environment variables in BASH shell (RHEL)
 
I've written a shell file in bash shell which has to set the environment variables. So, that i can call that file from some other shell programs.

The contents of my shell file looks like as below

JAVA_HOME=/usr/java/jdk1.5.0_18
export JAVA_HOME
POSIDEX_HOME=/home/posidex/posidex_n/hdfc
export POSIDEX_HOME
CLASSPATH=$POSIDEX_HOME/extlib/psxrpgeneric.jar:$POSIDEX_HOME/extlib/posidex.jar:$POSIDEX_HOME/extlib/classes12.jar:$POSIDEX_HOME/extlib/log4j_12.jar:$POSIDEX_HOME/extlib/mail.jar:$POSIDEX_HOME/extlib/activation.jar:$POSIDEX_HOME/prop
HASH_LOGGER_PROPS=$POSIDEX_HOME/prop/loggerhash.prop
export HASH_LOGGER_PROPS
ORP_LOGGER_PROPS_CUST=$POSIDEX_HOME/prop/loggercust.prop
export ORP_LOGGER_PROPS_CUST
ORP_LOGGER_PROPS_APPL=$POSIDEX_HOME/prop/loggerappl.prop
export ORP_LOGGER_PROPS_APPL
ORP_LOGGER_PROPS_TIPS=$POSIDEX_HOME/prop/loggertip.prop
export ORP_LOGGER_PROPS_TIPS
PRIMEPROP_SKEL_HOME=$POSIDEX_HOME/prop/enginepropskel/primematch
export PRIMEPROP_SKEL_HOME
PRIMEPROP_HOME=$POSIDEX_HOME/prop/engineprop/primematch
export PRIMEPROP_HOME
DBPROP_HOME=$POSIDEX_HOME/prop/dbprop
export DBPROP_HOME


The problem is the above things are worin' out
After running the shell file if i check
echo $JAVA_HOME
it displays nothing what could be the mistake

veerain 06-04-2009 04:36 AM

Did you run echo $HAVA_HOME in the parent shell.

druuna 06-04-2009 04:41 AM

Hi,

Are you executing the script or parsing it?

If you execute it the variables will only be accessible in the child shell, _not_ the shell you executed the script. If you parse the script the variables are accessible in the parent (mother) shell.

Executing: ./file
Parsing: . file (there's a space between the dot and the file)

Hope this helps.


All times are GMT -5. The time now is 09:25 AM.