[SLUG] two simple questions about bash and the path

From: Eric Jahn (eric@ejahn.net)
Date: Tue Mar 11 2003 - 13:34:57 EST


These two questions have annoyed me for so long I must set about
resolving them:

#1 Why does my $PATH get shrunk when I su to another user? For example:

ejahn@localhost ejahn $ echo $PATH
/usr/kde/3.1/bin:/bin:/usr/bin:/usr/local/bin:/opt/bin:/opt/sun-j2sdk-1.4.1/jre:/usr/i686-pc-linux-gnu/gcc-bin/3.2:/usr/X11R6/bin:/opt/sun-j2sdk-1.4.1/bin:/opt/sun-j2sdk-1.4.1/jre/bin:/usr/qt/3/bin:/usr/kde/3.1/bin:/usr/qt/2/bin
ejahn@localhost ejahn $ su root
Password:
root@localhost ejahn # echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin
root@localhost ejahn # su ejahn
ejahn@localhost ejahn $ echo $PATH
/usr/local/bin:/usr/bin:/bin

So why did the path for "ejahn" path get truncated? All I did was su
out, then back in.

#2 Why do I have to be in the exact directory to run a shell script?
Why can't I just use the full path? For example:

ejahn@localhost ejahn $ sh /opt/limewire/runLime.sh
Exception in thread "main" java.util.zip.ZipException: No such file or
directory
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(ZipFile.java:112)
        at java.util.jar.JarFile.<init>(JarFile.java:117)
        at java.util.jar.JarFile.<init>(JarFile.java:55)
ejahn@localhost ejahn $ cd /opt/limewire/
ejahn@localhost limewire $ sh runLime.sh
(now limewire starts fine)

Why won't bash accept a full path?

Thanks for any thoughts on these annoying things... -eric



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 16:49:15 EDT