After writing a shell script on Windows and trying to execute it on Linux, I got the following error message:
/bin/sh^M: bad interpreter: No such file or directory
The problem is obviously because the return line character on Windows and Linux are different. But how to fix it in order to execute it on Linux?
I firstly tried to open it, copy the content of the file and paste it in a new file using only Linux command line, but it didn’t work. 🙁
However, I found the following thread which fixed the problem:
http://www.reachdba.com/showthread.php?335-bin-sh-M-bad-interpreter-No-such-file-or-directory-apps11i-Instalation
Here is what you need to do:
- Open your file using vi
- Write the command
:set fileformat=unix
- Save the file using
:wq
The file should now run on Linux. 🙂
#1 by Ronny Roethof on 24 Oct 2012 - 14:37
or use dos2unix.. probably easier.
kvm01:~# sudo apt-get install dos2unix
kvm01:~# dos2unix domains.txt
dos2unix: converting file domains.txt to Unix format …
thats it