分类: LINUX
2008-06-11 16:19:03
Since moving the sites over to the new CentOS a couple of days ago, I began testing some existing that I had copied over from the old today. When I executed the first script, it failed, giving me this : 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 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! :)