Analytic

Monday, October 15, 2007

bad interpreter: No such file or directory

I get the following message when I try to run a simple test script. The same script runs on another machine very similar to my own.

./myfile: /bin/bash^M: bad interpreter: No such file or directory

The file does has execute rights.

In Windows, the end of a line is CRLF (Carriage-Return, Line-Feed). In Unix-like systems, it is just LF. So when you try to run that script, every line has an extra CR on the end.

The way to fix this is to use some sort of utility to fix that. You might use the utility dos2unix if you have it installed. You can install it by typing:

apt-get install tofrodos

No comments: