User Tools

Site Tools


Sidebar

Index

linux:bash:bad-interpreter-no-such-file-or-directory

Bash: Bad interpreter: no such files or directory

Scenario

When you try to run a bash script you receive this error -bash: ./controller.sh: /bin/bash^M: bad interpreter: No such file or directory

In my case this happens systematically if I transfer bash files with FTP (e.g. Filezilla) from one Linux computer to another Linux computer because FTP standard for text file transforms CR into CR+LF

According to the FTP specification, ASCII files are always transferred using a CR+LF pair as line ending.

Another source of problem is editing bash files into Windows OS (you will be damned forever if you do it!)

Solution

When possibile, lock FTP on using binary mode for everything.

On Windows use an editor that allow to force *nix line ending with CR (e.g. notepad ++ or Eclipse)

For bash files already “corrupted” use:

dos2unix <file.sh>

linux/bash/bad-interpreter-no-such-file-or-directory.txt · Last modified: 2014/09/12 15:09 by rik