LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   #!/bin/sh not honored (https://www.linuxquestions.org/questions/linux-newbie-8/bin-sh-not-honored-428165/)

deshengzhang 03-24-2006 05:56 PM

#!/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.

RobertP 03-24-2006 06:02 PM

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

IBall 03-25-2006 12:47 AM

/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

michaelk 03-25-2006 08:41 AM

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.

dopehouse 03-25-2006 11:01 AM

Have you made the script executable by doing:
Code:

chmod +x ScriptFile
Now you can run it with ./ScriptFile

If not, your script have to be run by by executing
Code:

sh or /bin/sh ScriptFile

deshengzhang 03-27-2006 12:55 PM

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.

IBall 03-27-2006 06:32 PM

Check out dos2unix for removing the ^M's. Also, unix2dos for putting them back :)

I hope this helps
--Ian

syg00 03-27-2006 07:25 PM

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 01:59 PM.