LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   calling another script , preserve environment variables? (https://www.linuxquestions.org/questions/linux-software-2/calling-another-script-preserve-environment-variables-770389/)

Umanga 11-20-2009 03:24 AM

calling another script , preserve environment variables?
 
Greetings all,

My first (main.sh) script is going to call the second script (settings.sh).I do it as follows:

Code:

#script1 - main.sh
sh config/settings.sh
echo $SGE_ROOT
echo $ARCH
echo $LD_LIBRARY_PATH


second script is as follows:

Code:

#script 2 - settings.sh
export SGE_ROOT=/SGE6.2/Root
export ARCH=lx24-amd64
export LD_LIBRARY_PATH=$SGE_ROOT/lib/ARCH/

But when I run main.sh I dont see output for the environment variables I set in settings.sh ?

Any tips?

Guttorm 11-20-2009 03:32 AM

Instead of:
sh config/settings.sh
Try this:
source config/settings.sh
Or shorter version:
. config/settings.sh


All times are GMT -5. The time now is 02:10 PM.