LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-26-2009, 03:23 PM   #1
steelangel
LQ Newbie
 
Registered: May 2007
Posts: 10

Rep: Reputation: 0
Shell scripts running from /usr/local/bin - what did I forget to do?


I haven't done shell scripting in a long while, and so I may have overlooked something. I need a second (or third or fourth) pair of eves.

I have written a shell script:
Code:
#!/bin/bash

latex $1.tex
dvips -t letter $1.dvi -o $1.ps
ps2pdf $1.ps $1.pdf
acroread $1.pdf
I have saved the shell script as the file /usr/local/bin/latexme. It is world-executable.
Code:
$ ls -aslt
...
8 -rwxr-xr-x 1 root root 94 Feb 26 10:38 /usr/local/bin/latexme
...
The directory /usr/local/bin is in my path.
Code:
$ echo $path
/usr/kerberos/bin /usr/local/bin /usr/bin /bin /usr/X11R6/bin
So, logically, I should see this when run from a directory:
Code:
$ latexme filename
(...latex/DVIPS/ output...)
Instead, I get:
Code:
$ latexme filename
latexme: Command not found.
However, this works:
Code:
$ /usr/local/bin/latexme filename
(...latex/DVIPS/ output...)
What obvious thing did I miss? For what it's worth, I'm using TCSH shell, and my distro is RHEL 5.
 
Old 02-26-2009, 03:32 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Ummm

What shell are you using?

$path isn't meaningful in any shell I've come across, and
$PATH should contain a colon-separated list of paths.



Cheers,
Tink
 
Old 02-26-2009, 04:00 PM   #3
steelangel
LQ Newbie
 
Registered: May 2007
Posts: 10

Original Poster
Rep: Reputation: 0
I'm using tcsh:

Code:
$ chsh
Changing shell for <username>.
Password: 
New shell [/bin/tcsh]: /bin/tcsh
Shell not changed.

$ echo $PATH
/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin

$ echo $path
/usr/kerberos/bin /usr/local/bin /usr/bin /bin /usr/X11R6/bin
You're right, $path should be $PATH, but that doesn't affect anything other than display.
 
Old 02-26-2009, 04:23 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Hmmm ... dunno; try using a sensible shell for a test. ;}
 
Old 02-26-2009, 05:20 PM   #5
steelangel
LQ Newbie
 
Registered: May 2007
Posts: 10

Original Poster
Rep: Reputation: 0
No need to be snarky :P

It works under bash. Why it doesn't work in tcsh I don't know.
 
Old 02-26-2009, 05:45 PM   #6
gergely89
Member
 
Registered: Feb 2009
Posts: 100

Rep: Reputation: 21
Your script begins with '#!/bin/bash' but you are not using a BASH shell to launch the script. It seems that your shell (tcsh) passes the lower-case $path to the launched 'bash' instance, which within the bash realm yields an empty string. Could be that tcsh only maintains $path as an environment variable, and the $PATH output is rather a helpful hint from tcsh (clearly - I have no idea).

The fact that launching the script by full pathname works OK indicates that this is related to $path/$PATH in some way.

By replacing the slashbang to '#!/bin/sh' you might get different results, because 'sh' is usually a link to the default shell executable - on many system it defaults to bash, but that's not carved in stone.

linux

Last edited by gergely89; 02-28-2009 at 12:05 AM.
 
Old 02-27-2009, 09:16 AM   #7
steelangel
LQ Newbie
 
Registered: May 2007
Posts: 10

Original Poster
Rep: Reputation: 0
I tried #!/bin/sh but that doesn't fit the issue; it still says that the command is not found.

On the $path vs. $PATH issue, I'm not exactly sure why it could be the source of the problem. Other executables run from the /usr/local/bin directory without the full path in the command line.
 
Old 02-27-2009, 09:26 AM   #8
steelangel
LQ Newbie
 
Registered: May 2007
Posts: 10

Original Poster
Rep: Reputation: 0
And.. it's fixed.

Apparenly the thing I forgot to do is to rehash. After a logout and login unrelated to this script issue, it suddenly started to work.
 
Old 02-27-2009, 09:28 AM   #9
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Edit: didn't see your fix before posting. That's ok. Normal behaviour in tcsh.

Last edited by colucix; 02-27-2009 at 09:29 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Subversion : /usr/local/bin/svnserve.bin lord-fu *BSD 2 12-17-2006 11:46 AM
making files available in /usr/local/bin and /usr/sbin reakinator Linux - Newbie 1 10-14-2006 06:09 PM
Error when starting up snort: bash:!/bin/sh/usr/local/bin/snort :Eent not found cynthia_thomas Linux - Software 1 11-11-2005 03:59 PM
Installing .bin-files, leave the file in /usr/local/bin/ ? lagu2653 Linux - Software 1 11-08-2005 09:30 PM
path in services wrong for clamav updated frm 0.75 to 0.80 usr/bin vs usr/local/bin Emmanuel_uk Linux - Newbie 3 04-22-2005 02:02 AM


All times are GMT -5. The time now is 12:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration