Red HatThis forum is for the discussion of Red Hat Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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.)
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.
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.