LinuxQuestions.org
Register a domain and help support LQ
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 03-24-2006, 06:56 PM   #1
deshengzhang
LQ Newbie
 
Registered: Mar 2006
Posts: 2

Rep: Reputation: 0
Question #!/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.
 
Old 03-24-2006, 07:02 PM   #2
RobertP
Member
 
Registered: Jan 2004
Location: Manitoba, Canada
Distribution: Debian
Posts: 454

Rep: Reputation: 32
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
 
Old 03-25-2006, 01:47 AM   #3
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 62
/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
 
Old 03-25-2006, 09:41 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 14,929

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
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.
 
Old 03-25-2006, 12:01 PM   #5
dopehouse
Member
 
Registered: May 2004
Location: Hildesheim(Germany)
Distribution: Debian Etch with Kernel 2.6.x (latest vanila)
Posts: 62

Rep: Reputation: 15
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
 
Old 03-27-2006, 01:55 PM   #6
deshengzhang
LQ Newbie
 
Registered: Mar 2006
Posts: 2

Original Poster
Rep: Reputation: 0
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.
 
Old 03-27-2006, 07:32 PM   #7
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

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

I hope this helps
--Ian
 
Old 03-27-2006, 08:25 PM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 14,832

Rep: Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820
What chance it was un-zipped in windows and copied over ???. Simple sed will fix the crlf issue.
 
  


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
sudo /usr/bin/chroot /home/chroot /bin/su - xxx| /bin/su: user xxx does not exist saavik Linux - General 3 07-04-2007 11:30 AM
Installing .bin-files, leave the file in /usr/local/bin/ ? lagu2653 Linux - Software 1 11-08-2005 09:30 PM
Is '/usr/bin/find' reliable if '/bin/ls' has been replaced? DigaMe Linux - Security 2 11-12-2004 11:42 PM
bin/bash:usr/bin/lpr NO SUCH FILE OR DIRECTORY Adibe_Hamm Linux - Newbie 3 10-14-2003 03:30 AM
Newbie needs help Installing j2sdk-1_4_2-nb_3_5_1-bin-linux.bin bendoku Linux - Newbie 5 10-11-2003 10:27 AM


All times are GMT -5. The time now is 08:47 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