Linux下执行.sh文件提示No such file or directory
来源:互联网 发布:数据库中的触发器 编辑:程序博客网 时间:2024/06/08 02:28
>在Linux中执行.sh脚本,异常/bin/sh^M: bad interpreter: No such file or directory。如图:
分析:这是不同系统编码格式引起的:在windows系统中编辑的.sh文件可能有不可见字符,所以在Linux系统下执行会报以上异常信息。
解决:
1)在windows下转换:
利用一些编辑器如UltraEdit或EditPlus等工具先将脚本编码转换,再放到Linux中执行。转换方式如下(UltraEdit):File-->Conversions-->DOS->UNIX即可。
2)也可在Linux中转换:
首先要确保文件有可执行权限
#chmod u+x filename
然后修改文件格式
#vi filename
利用如下命令查看文件格式
:set ff 或 :set fileformat
可以看到如下信息
fileformat=dos 或 fileformat=unix
利用如下命令修改文件格式
:set ff=unix 或 :set fileformat=unix
:wq (存盘退出)
最后再执行文件
#./filename
0 0
- Linux,执行.sh文件,提示No such file or directory
- Linux,执行.sh文件,提示No such file or directory
- Linux下执行.sh文件提示No such file or directory
- Linux下执行.sh文件提示No such file or directory
- Linux下执行.sh文件提示No such file or directory
- Linux下执行.sh文件提示No such file or directory
- linux下执行Sh文件报告bin/sh^M: bad interpreter: No such file or directory
- linux下执行Sh文件报告bin/sh^M: bad interpreter: No such file or directory
- Linux执行.sh文件,提示No such file or directory的问题
- 三种关于Linux执行.sh文件,提示No such file or directory错误的解决办法
- Linux执行.sh文件,提示No such file or directory的问题
- Linux执行.sh文件,提示No such file or directory的问题的解决方法
- Linux执行.sh文件,提示No such file or directory的问题的解决方法
- Linux执行.sh文件,提示No such file or directory的问题
- Linux执行.sh文件时提示No such file or directory
- Linux执行.sh文件,提示No such file or directory的问题的解决方法
- Linux执行.sh文件,提示No such file or directory错误
- Linux下执行脚本提示No such file or directory
- 沈国舫就一条十几天热火
- lgkgjk
- 8/7 customErrors in production
- Arm Instruction Condition Codes
- Servlet 手记
- Linux下执行.sh文件提示No such file or directory
- 漂亮的验证码(.Net MVC)
- 1111111
- irruryhg
- 装饰者模式
- 个结婚那你看克服地方哦批价哦
- kgjkjh
- orroriuury
- LeetCode刷题笔录Next Permutation