shell script/export question
Wojciech Komornicki
wnk at hamline.edu
Sat Mar 4 23:35:43 UTC 2006
>>>>> "bruce" == bruce <bedouglas at earthlink.net> writes:
bruce:> hi..
bruce:> i have the following simple script...
bruce:> # .foo
bruce:> # User specific environment and startup programs
bruce:> JAVA_HOME=/opt/IBMJava2-141
bruce:> export JAVA_HOME
bruce:> -------------------
bruce:> when i do a >./foo.sh, and then do a echo $JAVA_HOME, i don't see the
bruce:> exported variable. foo.sh has the exe bit set (777). any idea what i'm doing
bruce:> wrong. i'm using fc4. i'm basically trying to figure out how to create a env
bruce:> var, and export the var.
When you run a program as
> ./foo.sh
(I am assumine that > is your shell prompt) you spawn a new shell
If you run the program as
> . ./foo.sh
you are telling the current shell to execute the commands in foo.sh. In
the first instance you are setting and exporting the variable JAVA_HOME
in the spawned shell. When that shell closes upon exit from foo.sh the
evironment variable is lost. I the second instance you are setting the
shell variable for the current shell.
--
Wojciech Komornicki
More information about the fedora-list
mailing list