Monday, April 10, 2006

shell script 'bad interpreter'

Keywords:
tomcat catalina.sh "bad interpreter" sh shell

Problem:
Can't execute the shell script on linux. Everything seems in fine. The environment variables required by the script, the $PATH and the script has user has execute permission on the script (chmod +x catalina.sh).

Error each time is
bad interpreter: No such file or directory

Solution:
DOS/Non-Ascii characters in the script! Not sure vi doesn't highlight this (as ^M for example) - it could be a quirk with that version of vi or the console being used (putty in this case).

The solution is simple:
dos2unix catalina.sh catalina.sh

Try again via:
./catalina.sh run

All works.