Re: Script export problem in FC3

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

 



Samuel Díaz García wrote:
> I need to modify the PATH environment using a script. My script is:
> 
> --begin--
> #!bin/sh
> export PATH=$PATH:/mydir
> --end--
> 
> If I run the export command in command line I have no problem, but when 
> I run my script, and I run
> 
> echo $PATH
> 
> I can see that the path environtment variable isn't changed.
> 
> What can be the problem?
> I'm root user when I run the script.

Try sourcing the script:
. scriptname
That makes the *current* shell run the commands in the script.

Otherwise, the shell you're typing into will start another shell process
to actually run the script. And the change in the PATH variable will
only be available to that script and the processes started by that
script (and the processes they start, and)...

You should understand that Unix processes are started by a "parent", and
may start "child" processes. So your shell's parent might be
gnome-terminal, which has a parent of init, which is the ultimate
ancestor of all processes on a Unix system.

And child processes *cannot* change their parent's state, including
their environment.

(For these purposes, Fedora is an implementation of Unix.)

Hope this helps,

James.

-- 
E-mail address: james | The sendmail configuration file is one of those
@westexe.demon.co.uk  | files that looks like someone beat their head on
                      | the keyboard.  After working with it... I can see
                      | why!


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

  Powered by Linux