Oct 10 2007

bad interpreter: No such file or directory


Categories:

Running shell scripts in Linux

The error:

bad interpreter: No such file or directory

can be attributed to not having the bash shell script installed, particularly if the first line of your script is as follows (spaced inserted after backslash to pass SecFilter):

#!/ bin/ bash  

However, it is more likely due to the formatting of your file.  If you FTP'd the file from a Windows machine onto a Linux server, then the file will contain Line Feeds (CR/LF's  = Carriage Return and Line Feeds) instead of simply Carriage Returns (CR's).   There are several solutions available that will let you reformat the file to CR before uploading it to your server:

Cleaning up DOS file with Perl

You can use Perl and run the following command on the file:

perl -i -pe's/\r$//;' <filename>  </filename> 

 

Cleaning up DOS file with DOS2UNIX

Alternatively, you can use the DOS2UNIX utility to clean up the file within a Windows Command Prompt (Browse to Start -> Run... -> and type "cmd.exe" to open the command prompt).  Copy your file and dos2unix.exe to the same directory, and execute:

dos2unix.exe <filename>  </filename> 

 

Upload your file in ascii mode

Once you've converted your DOS file back into a UNIX (Linux friendly) format, make sure you upload it in ascii mode via your FTP client (not binary mode).

Average: 5 (1 vote)
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Textual smileys will be replaced with graphical ones.

More information about formatting options

Captcha
This question is used to make sure you are a human visitor and to prevent spam submissions.
Copy the characters (respecting upper/lower case) from the image.