LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Unable to export variables declared in a script (https://www.linuxquestions.org/questions/linux-newbie-8/unable-to-export-variables-declared-in-a-script-377157/)

joehansen12 10-26-2005 02:07 PM

Unable to export variables declared in a script
 
hi all,

How do I declare/initialize an environment variable in a script?

i have a file named set-abcd.sh.

*** setabcd.sh *****
MESS=hello ; export MESS
echo $MESS
******************

$ MESS=yahoo ; export MESS
$ echo $MESS
yahoo
$ ./set-abcd.sh
hello
$ echo $MESS
yahoo

Please help!

thanks,
Joe

Tinkster 10-26-2005 02:09 PM

Works as designed. What you want to do isn't to RUN
the script, but instead source it.

E.g.
Code:

. my_script.sh
or
Code:

source my_script.sh

Cheers,
Tink

joehansen12 10-26-2005 02:25 PM

thanks tinkster! source did the trick!


All times are GMT -5. The time now is 03:38 AM.