问题

执行某些shell脚本时,报错:bad interpreter

解决方案

系统必须安装脚本使用的shell。

每个shell脚本在脚本的顶部指定了默认解释器。例如:

#!/bin/sh
# This is...
clear
A=`pwd`
...
.....
...

##/bin/sh是执行该脚本的默认解释器。

检查是否已安装/bin/sh

$ ls /bin/sh

如果未安装/bin/sh,请使用rpm,up2date或apt-get命令安装所需的Shell。

另一个问题是,如果脚本是在windows上编写的,则脚本中将显示CR/CRLF符号。
这时需要使用dos2unix命令将这些脚本转换为UNIX格式。

dos2unix script-file-name
执行Shell脚本报错:bad interpreter
日期:2019-11-20 08:52:57 来源:oir作者:oir