执行脚本出现bin/bash: bad interpreter: No such file or directory
-bash: ./test.sh: /bin/bash^M: bad interpreter: No such file or directory
VI打开文件,没发现任何问题,
把/bin/bash改成/bin/sh
-bash: ./test.sh: /bin/sh^M: bad interpreter: No such file or directory
依然报错,脚本内容在VI下没有任何问题,仔细一看错误消息,^M..明显在第一行末尾被加入了个^M,
这种情况应该有两种原因
1.在WIN底下用文本编辑工具修改过参数变量,在保存的时候没注意编码格式造成的,
2.也有可能是在VIM里修改,第一行末尾按到ctrl_v
错误原因之一很有可能是你的脚本文件是DOS格式的, 即每一行的行尾以\r\n来标识, 其ASCII码分别是0x0D, 0x0A.
可以有很多种办法看这个文件是DOS格式的还是UNIX格式的, 还是MAC格式的
(1). vi filename
然后用命令
:set ff?
可以看到dos或unix的字样. 如果的确是dos格式的, 那么你可以用set ff=unix把它强制为unix格式的, 然后存盘退出. 再运行一遍看.
2.可以用执行dos2unix 命令转换编码
#dos2unix myshell.sh
3..也可以用sed 这样的工具来做:
sed 's/^M//' filename > tmp_filename
mv -f tmp_filename filename
来做
特别说明:^M并不是按键shift + 6产生的^和字母M, 它是一个字符, 其ASCII是0x0D, 生成它的办法是先按CTRL+V, 然后再回车(或CTRL+M)
关于^M
new line of DOS/Windows
new line of dos/win: 0X0d0a
new line of linux/unix: 0X0a
执行脚本出现bin/bash: bad interpreter: No such file or directory的更多相关文章
- 转载:执行脚本出现bin/bash: bad interpreter: No such file or directory
转载网址:http://blog.csdn.net/red10057/article/details/8051650 刚刚学习 SHELL 写了一个简单的例子 发生如下错误 -bash: ./test ...
- 【转】执行脚本出现bin/bash: bad interpreter: No such file or directory
[转自]http://blog.csdn.net/wind19/article/details/4822666 错误原因之一很有可能是你的脚本文件是DOS格式的, 即每一行的行尾以/r/n来标识, 其 ...
- Linux学习笔记之Linux shell脚本运行出现问题:bash: ./test: bin/sh: bad interpreter: No such file or directory
问题: 在Linux系统中使用“vi test.sh”命令创建.sh文件,保存文件(:wq)并赋予权限(chmod +x test.sh)后,执行(./test.sh),出现问题:“bash: ./t ...
- centos 7安装mysql报错-bash: ./scripts/mysql_install_db: /usr/bin/perl: bad interpreter: No such file or directory
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql -bash: ./scripts/mysql_install_db: ...
- -bash: /usr/bin/yum: /usr/bin/python: bad interpreter: No such file or directory
-bash: /usr/bin/yum: /usr/bin/python: bad interpreter: No such file or directory python多版本造成额问题 找不到p ...
- -bash: /usr/local/mysql/scripts/mysql_install_db: /usr/bin/perl: bad interpreter: No such file or directory
安装 MySQL 初始化时,报错如下: [root@hcdb1 ~]# /usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/m ...
- python/shell脚本报异常^M: bad interpreter: No such file or directory
问题:在Windows写了一python脚本,上传Linux服务器执行,报异常*****^M: bad interpreter: No such file or directory 原因:window ...
- sh脚本异常,binsh^M bad interpreter No such file or directory
错误 在Linux中执行.sh脚本,出现如下异常 /bin/sh^M: bad interpreter: No such file or directory 原因 在windows系统中编辑的.sh文 ...
- docker容器启动时执行脚本 run /bin/bash执行多条指令
搜了很多资料发现并未解决,以下方法失败!求大神评论给出完美方案 1.首先需要编写需要启动的脚本,并将脚本放在 /etc/init.d/目录下 如:cs.sh 2.修改权限 3.chkconfig -- ...
随机推荐
- WebApi接口访问频率控制的实现
关于限流的文章,博客园内还是有挺多的.本文做了一个基于Filter限流的例子,算是对WebApiThrottle使用的一个具体的实例. 实现方法: 1.使用Nuget,对WebAPI项目添加WebAp ...
- Extjs 下拉框下拉选项为Object object
使用Extjs的下拉框出现下拉选项为Object object的问题. 原因在于对store属性提供的是data信息,而不是store对象
- 单行bash、shell、perl命令
主题:单行经典bash.shell.perl命令 作者:luomg 摘要: 会陆陆续的写自己工作中的常用有意思的命令,争取你能看完后就能搞定常见操作, 且尽量自少提供基本shell.perl的实现方式 ...
- 如何破解UltraEdit
在断网的前提下,软件->帮助->注册->激活->脱机激活—>用户和密码随便输入->还有两个空着,就是该用注册机激活了. 打开注册机->输入ULtredit的自 ...
- action属性
action属性 2013年7月8日 14:52 Path: action的访问路径,以"/"开头 Type: action的类型 Name: action使用的actionFor ...
- 模仿cocos2dx 风格用工厂方法,实现class A,不使用宏,
class A { static A *create(); bool init(); }; A* A::create() { A *pRet=new A; if(pRet && pRe ...
- c++中的virtual函数,即虚函数
c++中的虚函数主要是用来实现多态的,虽然都同时指向父类的实例.但调用的确实子类的函数,这个有点像java的接口和实现的关系了.一个接口有多种实现,一个接口对象调用的是哪个实现的方法,这个就是多态了 ...
- 四则运算(2)之软件单元测试:Right-BICEP
一.Right-BICEP主要测试以下几方面的问题: Right-结果是否正确? B-是否所有的边界条件都是正确的? I-能查一下反向关联吗? C-能用其他手段交叉检查一下结果吗? E-你是否可以强制 ...
- 搬瓦工VPS搭建PPTP VPN
之前一直在用神器Lantern和Nydus(20元一个月),感觉还不错,但是各有各的不足! 于是开始自己动手折腾用VPS搭建VPN... 上网逛了一圈,最后选择了搬瓦工的VPS:512RAM,10G ...
- 学习Linux第五天
1.VIM编辑器 3种模式: Command Model , Insert Model , Last line Model 安装vim: sudo apt-get install vim 如果提示出错 ...