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?
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.
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.
Summary: Hi, I have installed a Solaris 10 x86. I have another PC with XP Pro with a Internet DSL Connection. I can ping from my Solaris 10 to internet addresses, but I can't navigate. I put a manual proxy con...
Summary: I'm just learning perl and I have a question. Can I use awk in a perl script? I tried this @s_users=`/usr/bin/last | head |awk {'print $1'}"` ; but it didn't work. The result is just the commans las...
Summary: get the script in current dir, and use ./<script>. or make the current dir in your path *not recomended because of security problems with root, never use "."in your PATH when you are a root, you ma...