Chinaunix首页 | 论坛 | 博客
  • 博客访问: 529963
  • 博文数量: 134
  • 博客积分: 7990
  • 博客等级: 少将
  • 技术积分: 1290
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-29 11:43
文章分类

全部博文(134)

文章存档

2009年(7)

2008年(80)

2007年(47)

我的朋友

分类: 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! :)

阅读(1212) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~