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

Friday, September 3, 2010


Symptom

Shell script in Linux fail to start and returns the following error message:

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

Cause
Due to different way of handling text file encoding, a Linux shell script might contains extra after transferring from a Windows machine to a Linux machine.

Resolution

1. Download DOS2UNIX utility and put it into the same directory as your shell script in a Windows machine.

2. Run Windows Command Prompt and execute:

dos2unix.exe <filename>

3. Once completed, upload the file in ASCII mode via your FTP client to the Linux machine and try running the shell script again.