Re: [SLUG] two simple questions about bash and the path

From: Eric Jahn (eric@ejahn.net)
Date: Tue Mar 11 2003 - 15:20:22 EST


Thank you all for your solutions to these quandaries of mine. Thanks!

On Tue, 2003-03-11 at 14:26, Matthew Walker wrote:
> --- Joe Burnsworth <jburnsworth@earthlink.net> wrote:
> >
> > When you su again, you are logging into that account *again*..
> >
> > Try typing exit to get back to your initial login.
> >
> > -Joe
> >
> >
> >
> > On 11 Mar 2003, Eric Jahn wrote:
> >
> > > 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)
>
> This is not an error generated by the shell, rather stderr. The file
> runLime.sh obviously runs some java code which is encountering an
> error. This is probably due to some assumptions made by the .sh when it
> is run, like establishing a $CLASSPATH based on the directory '.' which
> it assumes is '/opt/limewire', (e.g. CLASSPATH=../lib/SomePacakge.jar)
>
> > >
> > > Why won't bash accept a full path?
> > >
> > > Thanks for any thoughts on these annoying things... -eric
> > >
> > >
> >
> >
> > _UPTIME_
> >
> >
>
> The wonderful thing about the shell env is that you can attack such an
> issue like 34 ways. One of which would be to make an alias that
> contains two commands one line separated by ';', e.g. cd /opt/limewire;
> runLime.sh
>
> You can then simply call the alias.
>
> >
>
> - Matt
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Web Hosting - establish your business online
> http://webhosting.yahoo.com



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 16:50:27 EDT