shell 脚本运行 提示bad interpreter:No such file or directory!

1032阅读 0评论2012-03-28 awool_cu
分类:Python/Ruby

 

Shell脚本运行,提示bad interpreter:No such file or directory错误!

 

    客户的服务器有cron运行。在旧的系统中正常。网站转移到我们新的服务器上,cron也完全copy。查看cron记录显示命令也运行了。但通过PHP文件生成的html文件没有内容。

  将shell 脚本的错误输出重定向到一个文件。

/root/test.sh   2> /home/admin/test.txt 将test.sh脚本的错误输出重定向到/home/admi/test.txt文件。

   打开test.txt文件:-bash: /root/test.sh : /bin/ksh^M: bad interpreter :No such file or directory

   网上查了下资料。是文件格式导致的,查看下test.sh的格式:

   vi test.sh

   输入:set ff 查看文件格式,出现 ileformat=dos,文件是DOS格式。使用:set ff=unix 强制将文件转换为unix格式。:wq 保存退出。再次域名test.sh脚本。文件正常输出。

上一篇:C语言分割字符串函数strtok!
下一篇:常用的Shell命令...(持续更新)