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.


 
 
 

10 Responses to “bad interpreter: No such file or directory”

  1. Koen
    17:32 on July 12th, 2008

    Thanks a lot. Solved my problem!

  2. tygern8r
    16:09 on February 17th, 2009

    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.

  3. anon
    11:27 on July 9th, 2009

    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

  4. heitara
    18:23 on August 3rd, 2009

    This post was very useful.
    The real treasure here is “tofrodos package”!

    10x!

    It solves a problems with ‘mxmlc’ under ubuntu 9.04.

  5. Phil
    21:32 on October 1st, 2009

    Just what I was looking for. Solved my problem! Thanks!!!

  6. Tomcat dummy
    09:16 on October 11th, 2009

    Dude, you rock.

    I have no clue how it got discombobulated, but you got it fixed. Thanks.

  7. Niranjan Ranade
    04:26 on November 17th, 2009

    Thanks a lot. This saved me a lot of time. dos2unix command works gr8 :)

  8. Manoj Kumar
    05:08 on December 14th, 2009

    thanks… it worked for me…

  9. Riadh Chougui
    19:33 on February 28th, 2010

    for those who don’t have the command, http://www.dos2unix.org does it for you online :p

  10. Paras Jain
    15:21 on May 27th, 2010

    Thanks it set ff=unix worked for me

Leave a Reply


Mmm, I am really impressed with NOVO coffee. Very good! Maybe it's just because I've been drinking the Folgers coffee at the office.

Just saved $290 by changing the damn radiator myself

Doh, I ran out of propane halfway through a brew session. That added an extra hour to an already long brew day.

Follow me on Twitter