GIDNetwork > bad interpreter: No such file or directory
Register
« ChronoPay Forms Strategic Alliance with Trusted Shops Alternative PHP Cache (APC) »

bad interpreter: No such file or directory

by: admin - May 01, 2006

Since moving the sites over to the new CentOS web server a couple of days ago, I began testing some existing bash scripts that I had copied over from the old server today. When I executed the first script, it failed, giving me this error message: bad interpreter: No such file or directory!

I figured I must have 'missed' a few lines when I did the copy and paste operation, but everything checked out fine... Must be the file permissions then, I thought -- well, that was not it either! Hmm...

Generic Code Example:

[jay@yumie ~]$ ./backup_db
: bad interpreter: No such file or directory

Despite what it says in the error message, the real problem is that I seem to have inadvertently inserted some DOS / Windows style linefeeds (i.e. "\r\n" instead of "\n") when I copied the contents of each file.

To fix this quickly and easily, I searched my Linux server for the dos2unix program.

Generic Code Example:

[jay@yumie ~]$ locate dos2unix
/usr/share/doc/dos2unix-3.1
/usr/share/doc/dos2unix-3.1/COPYRIGHT
/usr/share/man/man1/dos2unix.1.gz
/usr/bin/dos2unix

To convert a file I simply had to type:
/usr/bin/dos2unix -o ./backup_db

Generic Code Example:

[jay@yumie ~]$ /usr/bin/dos2unix -o ./backup_db
dos2unix: converting file ./backup_db to UNIX format ...

Re-ran the script and everything works again; no more error messages, not even misleading ones! :)

Would you like to comment? This story has been viewed 16,037 times.
« ChronoPay Forms Strategic Alliance with Trusted Shops Alternative PHP Cache (APC) »

__top__

Copyright © GIDNetwork™ 2001 - 2017

Another website by J de Silva

Page generated in : 0.02894 sec.