Computing.Net > Forums > Solaris > Why can't rewrite PATH through a script?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Why can't rewrite PATH through a script?

Reply to Message Icon

Name: shellscript
Date: July 22, 2002 at 09:09:49 Pacific
Comment:

I wrote a bash script to clean up duplicate directoris and garbage from PATH variable and set a new path into $newpath. However, even if I embbeded the following codes into my script, I still can't update PATH environment variable.

export PATH=$newpath

Any comments or suggestions?

By the way,
1) I don't have administrator;
2) only an attribute "-x" has been set for PATH variable.
3) If the script exports "PATH=/usr/bin:/etc/local..." into a temporary file .tmp_path, then I use "source .tmp_path" at command line, PATH can be updated.

Many thanks



Sponsored Link
Ads by Google

Response Number 1
Name: Jerry Lemieux
Date: July 23, 2002 at 11:50:02 Pacific
Reply:

You just answered you own question. You will have to source your script in order to get the variable replaced. Using -x will only export to shells spawned by your script. They will not export to the parent shell because your script is a sub-shell of your login shell. You may want to consider putting this stuff in your .profile (or whatever bash uses). Your .profile gets sourced when you log in and can perform the functions you are trying to do with a script. Perhaps you may want to source your script from your .profile.

Jerry


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Solaris Forum Home


Sponsored links

Ads by Google


Results for: Why can't rewrite PATH through a script?

I can't navigate from Solaris 10 www.computing.net/answers/solaris/i-cant-navigate-from-solaris-10/4673.html

Can I use awk in a perl script? www.computing.net/answers/solaris/can-i-use-awk-in-a-perl-script/4359.html

i can not run a script www.computing.net/answers/solaris/i-can-not-run-a-script/4113.html