shell script/export question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>>>>> "bruce" == bruce  <bedouglas@xxxxxxxxxxxxx> 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


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux