Re: shell script/export question

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

 



On Sat, 2006-03-04 at 14:07, bruce wrote:
> hi..
> 
> i have the following simple script...
> 
> # .foo
> # User specific environment and startup programs
> 
> JAVA_HOME=/opt/IBMJava2-141
> export JAVA_HOME
> 
> -------------------
> 
> when i do a >./foo.sh,

That command will send your stdout to a file named foo.sh,
overwriting it's current contents.  Is that what you
intended?

>  and then do a echo $JAVA_HOME, i don't see the
> exported variable. foo.sh has the exe bit set (777). any idea what i'm doing
> wrong. i'm using fc4. i'm basically trying to figure out how to create a env
> var, and export the var.

The environment is only exported to programs started by the
one that exported it - that is, you can't affect your parent
process.  Normally, commands are executed in subshells that
exit when finished.  For the cases where you want to execute
commands in your current shell, you must 'source' the file
containing them. You can abbreviate the source command as '.',
but probably want you really want is to put the commands in
the files that are always sourced by your login shell which
would be .profile for yourself or /etc/profile for everyone.
There are also shell-specific variations of this, like
.bash_profile and ones that are also source by subshells
(so they can contain functions) like .bashrc.

-- 
  Les Mikesell
   lesmikesell@xxxxxxxxx
If you want to execute commands in your current
shell


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

  Powered by Linux