LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


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

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


Hello,

problems with init.d script

OS Redhat v 9.0
custom install - server

Background:

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
error:

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?
#!/bin/bash
#
# 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
start)
echo -n "Starting vsftpd service: "
daemon --root chroot /home/jail/ /usr/local/sbin/vsftpd
echo
;;
stop)
echo -n "Stopping ftp services: "
killall vsftpd
echo
;;
status)
status vsftpd
;;
restart)
/etc/rc.d/init.d/vsftpd stop
/etc/rc.d/init.d/vsftpd start
;;
*)
echo "Usage: vsftpd {start|stop|status|restart}"
exit 1
;;
esac

exit 0

Help please?
 
Old 07-14-2004, 05:24 PM   #2
Savahn
Member
 
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, 09:41 AM   #3
snowmedia
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, 11:24 AM   #4
scoghill
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, 09:48 AM   #5
snowmedia
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, 11:12 AM   #6
zwc94
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, 05:03 PM   #7
bdmeyer
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:
wget http://www.internetsecurityguru.com/barnyard

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

--Bruce D. Meyer
 
Old 06-10-2009, 01:44 AM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,342

Rep: Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746
@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, 06:16 PM   #9
czechspy
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
 
  


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

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 09:58 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
Open Source Consulting | Domain Registration