执行shell时出现No such file or directory问题

Posted Z-hhhhh

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了执行shell时出现No such file or directory问题相关的知识,希望对你有一定的参考价值。

一、对于在服务器上新上传的start.sh脚本,启动时容易出现,-bash:./start.sh:/bin/sh^M: bad interpreter:No such file or directory

一般情况是因为该sh脚本的格式不正确,如果这个脚本在你本地修改过(使用txt、notepad++打开修改),可能在保存的时候会默认把文件的格式保存为: doc格式(windows系统)、mac(苹果系统),那么在上传到系统后,unix系统是不支持doc(mac)格式的,那么就需要把doc(mac)格式的文件修改为unix格式即可。

具体操作步骤如下:
1、执行命令 vi start.sh
2、执行 :set ff (这里是查看.sh文件的格式,如果在左下角你看到 fileformat=doc 或 fileformat=mac,fileformat=dos,继续执行下边的步骤,个人感觉不是unix 的都要改)
3、执行命令 :set ff=unix (修改为unix格式)
4、执行命令 :wq (保存即可)
5、保存完即可,这个时候也可以 vi start.sh 进去 :set ff 确认一下格式是否修改了。

以上是关于执行shell时出现No such file or directory问题的主要内容,如果未能解决你的问题,请参考以下文章

执行shell时出现No such file or directory问题

新手求助安装linux时出现zsh:no such file or directory:/arch

安装torch7时出现致命错误:errno.h: No such file or directory

Python 安装zbar-py时出现 无法打开包括文件: “unistd.h” no such file or directory

使用mipsel-linux-gcc时出现No such file or directory (解决)

使用mipsel-linux-gcc时出现No such file or directory (解决)