469,125 Members | 1,753 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,125 developers. It's quick & easy.

scripts execute while in /bin, but not anywhere else

I'm teaching myself UNIX, here, and I've written a shellscript that works fine if I use it while in the /bin directory, but if I try to use it from another directory, I get 'command not found'.

echo $PATH shows me the /bin folder
find shows me that the script is actually in that folder
my .cshrc file has its PATH set to that folder

I don't know what's going wrong. I have a script that someone else wrote that seems to work fine wherever it's used (though I don't want to test that, as it's a script that dumps the contents of the ls file onto someone else's screen - not very nice. My friend wrote it to show me scripting, and has a rather retaliatory sense of humour). but I can't see any difference between the basics of his script and mine.

Please help? I wouldn't be surprised if this is some really stupid error (it's what generally happens when you're teaching yourself) but I can't figure it out.
Jun 22 '07 #1
4 1924
prn
254 Expert 100+
Hi Avaenuha,

The key information you have given us is that
echo $PATH
shows /bin (but evidently not anything else). Your problem looks to be that you are not looking anywhere else for your script. If, for example, your script is in /home/Avaenuha then you could run it with /home/Avaenuha/scriptname. Or, as another possibility, you could add a line like

setenv PATH $PATH:$HOME

to your .cshrc file, which will make your csh command interpreter look for scripts in your $HOME directory as well as in your previous PATH.

HTH,
Paul
Jun 22 '07 #2
archonmagnus
113 100+
Try using the "sh" command like so:
Expand|Select|Wrap|Line Numbers
  1. sh <scriptname>
  2.  
"sh" is a shell interpreter and so parses the input file as a script. "sh" is in the /bin path, so it can be used in any directory with a script in it.
Jun 22 '07 #3
Try using the "sh" command like so:
Expand|Select|Wrap|Line Numbers
  1. sh <scriptname>
  2.  
"sh" is a shell interpreter and so parses the input file as a script. "sh" is in the /bin path, so it can be used in any directory with a script in it.
Thanks for your help, that's sorted it out.
Jul 2 '07 #4
Motoma
3,237 Expert 2GB
I think the most likely case, judging by the solution, was that the permissions on the shell script were not set to execute.
Jul 2 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

13 posts views Thread by Jon Cosby | last post: by
6 posts views Thread by windozbloz | last post: by
8 posts views Thread by Leszek | last post: by
31 posts views Thread by Manfred Kooistra | last post: by
1 post views Thread by =?Utf-8?B?TGVvbiBNYXluZQ==?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.