Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Red Hat This forum is for the discussion of Red Hat Linux.


  Search this Thread
Old 07-14-2004, 10:35 AM   #1
LQ Newbie
Registered: Jun 2004
Distribution: redhat
Posts: 6

Rep: Reputation: 0
Question init.d script error bad interpreter


problems with init.d script

OS Redhat v 9.0
custom install - server


created script below to stop/start/restart chroot environment
located in /etc/rc.d/init.d/ called vsftpd

While logged in as root:
run /etc/rc.d/init.d/vsftpd start

recieve error:
Bad interpreter : File or directory not found

Run bash --debug /etc/rc.d/init.d/vsftpd start

Error: file or directory not found

. /etc/rc.d/init.d/functions

run service vsftpd start

env: /etc/init.d/vsftpd : no such file or directory

I am not sure why the Redhat init.d is not recognizing the script

ran chkconfig --add vsdtpd
no errors.

Add the command I want to run in /etc/rc.d/rc.local
reboot the command runs fine
run . /rc.local start or /rc.local stop while in /etc/rc.d/ directroy command runs.

I believe it is with the file vsftpd in /etc/rc.d/init.d/
What can I do? What have I forgotten to edit?
Has anyone seen this error?
# vsftpd Start/Stop the vsftpd daemon
# description: vsftpd is a script for starting/stopping/etc vsftpd server
# version 1.00
# chkconfig: 345 96 77
# processname: vsftpd
# processconfig: /home/jail/etc/vsftd.conf

# Source function library.
. /etc/rc.d/init.d/functions

# See how we were called.
case "$1" in
echo -n "Starting vsftpd service: "
daemon --root chroot /home/jail/ /usr/local/sbin/vsftpd
echo -n "Stopping ftp services: "
killall vsftpd
status vsftpd
/etc/rc.d/init.d/vsftpd stop
/etc/rc.d/init.d/vsftpd start
echo "Usage: vsftpd {start|stop|status|restart}"
exit 1

exit 0

Help please?
Old 07-14-2004, 06:24 PM   #2
Registered: Mar 2003
Posts: 36

Rep: Reputation: 16
Instead of using #!/bin/bash as the command interperator you might try using #!/bin/sh
Old 07-15-2004, 10:41 AM   #3
LQ Newbie
Registered: Jun 2004
Distribution: redhat
Posts: 6

Original Poster
Rep: Reputation: 0
Yes, that is a good idea. So I tried it both ways !/bin/bash and !/bin/sh. Recieved the error in both cases.

I am going to try and copy a known working script and edit it.
Old 12-07-2005, 12:24 PM   #4
LQ Newbie
Registered: Dec 2005
Posts: 2

Rep: Reputation: 0
Thumbs up Extraneous whitespace

I found this post with a Google search because I was having the same problem. I executed my script directly and got the same errors. I looked at my script and the #!/bin/sh was correct. What could it be. Then I fired up vi to look at the file and tried to retype the sha-bang line. It looked VERY funny.

Did a hexdump -C on the script and, lo and behold, there is an extra <CR> at the end of each line!

I created the file with Textpad on my PC, saved it to a directory mapped by Samba, and didn't think anything of it. Everything but the script invocation worked. The problem was that I had forgot to tell Textpad to save the file in UNIX format instead of PC format.

Once I resaved the file in UNIX format, it worked just fine.

(I know this is kinda late, but this post came up third in my Google search. So, I figure someone else is likely to hit it as well looking for what can cause this problem.)
Old 12-08-2005, 10:48 AM   #5
LQ Newbie
Registered: Jun 2004
Distribution: redhat
Posts: 6

Original Poster
Rep: Reputation: 0
Very good...

I appreciate the follow-up. I could never figure it out, and I am not strong in C code. So,I ended up just copying a working init.d script and removing all stuff unrelated to my needs. I performed all of this in vi. Where as before my original script, i did the same thing as you, I edited it in notepad. I know now, one way around this problem is to use dos2unix prog that removes all unwanted <cr> or <n>. I had a similar problem with a script, and it helped remove the window's nasties.

It is always nice to know why, and I thank you for your work.
Old 02-06-2009, 12:12 PM   #6
LQ Newbie
Registered: Feb 2009
Posts: 1

Rep: Reputation: 0
thanks scoghill I ran into that exact same problem! Saved the file w/out <CR> 's and it works great.

Here's my error for google (was setting up bind9, named on redhat)

service named start
env: /etc/init.d/named: No such file or directory
Old 06-07-2009, 06:03 PM   #7
LQ Newbie
Registered: Dec 2007
Posts: 4

Rep: Reputation: 0
Easy fix

Same here. try instead of changing editors, modes etc, just enter:
dos2unix (filename) and if it is indeed an extra <cr> this will fix it. I used this to fix:

env: /etc/init.d/barnyard: No such file or directory

After retrieving the file via:

Service starts properly after running the unix2dos barnyard.
(be sure to chmod 755 barnyard)

--Bruce D. Meyer
Old 06-10-2009, 02:44 AM   #8
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.5
Posts: 17,710

Rep: Reputation: 2509Reputation: 2509Reputation: 2509Reputation: 2509Reputation: 2509Reputation: 2509Reputation: 2509Reputation: 2509Reputation: 2509Reputation: 2509Reputation: 2509
@snowmedia: I hope that's not RH9 (Shrike); that was discontinued in 2003(?), so its unsupported/ wide open to exploits by now
Old 10-01-2011, 07:16 PM   #9
LQ Newbie
Registered: Oct 2011
Posts: 1

Rep: Reputation: Disabled
Good call

Good call scoghill!

Another workaround was posted by ghostdog74

tr -d '\r' < input.file > new.file


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
User executing script: bad interpreter: Permission denied stefaandk Linux - Newbie 7 06-27-2005 10:53 AM
bad interpreter error zum Linux - Software 3 05-31-2005 11:01 AM
bad interpreter in script c0d3 Programming 11 12-15-2004 05:48 AM
bad interpreter error message ffenics2002 Linux - Software 2 04-15-2004 01:17 PM
script: bad interpreter... chunkymunky Programming 6 12-25-2003 10:58 PM > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 01:16 PM.

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