bad interpreter: No such file or directory
When my tomcat context suddenly wouldn’t start anymore I found myself scratching my head. I couldn’t figure out why the startup.sh script always threw the error
bash: ./catalina.sh: /bin/sh^M: bad interpreter: No such file or directory
After investigating for a while I found that I had two seemingly identical files. One would run fine, the other threw a “bad interpreter” error.
Apparently if a shell script gets opened and saved in notepad it will not run anymore.
A simple “dos2unix catalina.sh” fixed the problem.
In Ubuntu the dos2unix binary can be found in the tofrodos package.

17:32 on July 12
Thanks a lot. Solved my problem!
16:09 on February 17
Thanks! Didn’t really feel like having to re-type the whole init script on the buntu box. I did find it strange that even when I opened the script with vim, I didn’t see any ^M or windows carriage returns. Fromdos fixed it for me.
11:27 on July 9
You can also solve this by opening the file with vim, go to the command : and type in set. You will see that fileformat is set to “dos”. Now go back to : and type in “set ff=unix”. That should also resolve the issue.
Greets
18:23 on August 3
This post was very useful.
The real treasure here is “tofrodos package”!
10x!
It solves a problems with ‘mxmlc’ under ubuntu 9.04.
21:32 on October 1
Just what I was looking for. Solved my problem! Thanks!!!
09:16 on October 11
Dude, you rock.
I have no clue how it got discombobulated, but you got it fixed. Thanks.
04:26 on November 17
Thanks a lot. This saved me a lot of time. dos2unix command works gr8
05:08 on December 14
thanks… it worked for me…
19:33 on February 28
for those who don’t have the command, http://www.dos2unix.org does it for you online :p
15:21 on May 27
Thanks it set ff=unix worked for me