#!/bin/sh not honored
We have recently installed a Redhat Linux. My account defaults to tcsh shell. When I tried to run a script that have the first line as #!/bin/sh, I got "command not found". So I have to run the script using /bin/sh scriptFile. Is there anything configuration I can do to get rid of this headache? Thanks.
|
The usual approach is to put a link in /bin to tcsh or whatever
ls -l /bin/sh lrwxrwxrwx 1 root root 4 2005-07-03 03:40 /bin/sh -> bash To make such a link execute this command as root: ln -s /bin/tcsh /bin/sh |
/bin/sh is normally a link to Bash, not to tcsh. If you make a link from /bin/tcsh to /bin/sh you will likely get problems, since applications expecting bash will not work with tcsh.
--Ian |
Or is it just an path environment problem. What happens when you use the command
./scriptfile Make sure scriptfile permissions are set for executable. Unlike windows linux only searches for a file using the users path. |
Have you made the script executable by doing:
Code:
chmod +x ScriptFile If not, your script have to be run by by executing Code:
sh or /bin/sh ScriptFile |
It turned out that the file is in Windows text format. My vi does not show those ^M's. After removing those, it worked fine. Thanks.
|
Check out dos2unix for removing the ^M's. Also, unix2dos for putting them back :)
I hope this helps --Ian |
What chance it was un-zipped in windows and copied over ???. Simple sed will fix the crlf issue.
|
All times are GMT -5. The time now is 06:52 PM. |