/bin/sh^M: bad interpreter: No such file or directory AND 使用Shell脚本查找程序对应的进程ID,并杀死进程
2012-08-09 16:59
861 查看
首先要确保文件有可执行权限
#sh>chmod a+x filename
然后修改文件格式
#sh>vi filename
利用如下命令查看文件格式
:set ff 或 :set fileformat
可以看到如下信息
fileformat=dos 或 fileformat=unix
利用如下命令修改文件格式
:set ff=unix 或 :set fileformat=unix
:wq (存盘退出)
最后再执行文件
#sh>./filename
#!/bin/sh
NAME=XXXX.jar
echo
$NAME
ID=`ps -ef | grep "$NAME" | grep -v "$0" | grep -v "grep" | awk '{print
$2}'`
echo $ID
echo "---------------"
for id in $ID
do
kill -9
$id
echo "killed $id"
done
echo
"---------------"
#sh>chmod a+x filename
然后修改文件格式
#sh>vi filename
利用如下命令查看文件格式
:set ff 或 :set fileformat
可以看到如下信息
fileformat=dos 或 fileformat=unix
利用如下命令修改文件格式
:set ff=unix 或 :set fileformat=unix
:wq (存盘退出)
最后再执行文件
#sh>./filename
#!/bin/sh
NAME=XXXX.jar
echo
$NAME
ID=`ps -ef | grep "$NAME" | grep -v "$0" | grep -v "grep" | awk '{print
$2}'`
echo $ID
echo "---------------"
for id in $ID
do
kill -9
$id
echo "killed $id"
done
echo
"---------------"
相关文章推荐
- 使用Shell脚本查找程序对应的进程ID,并杀死进程
- 使用Shell脚本查找程序对应的进程ID,并杀死进程
- 使用Shell脚本查找程序对应的进程ID,并杀死进程
- 使用Shell脚本查找程序对应的进程ID,并杀死进程
- 使用Shell脚本查找程序对应的进程ID,并杀死进程
- 使用Shell脚本查找程序对应的进程ID,并杀死进程
- shell脚本中报 “/bin/sh^M: bad interpreter: 没有那个文件或目录”解决方法
- shell脚本报错:-bash: xxx: /bin/sh^M: bad interpreter: No such file or directory
- shell脚本报错:-bash: xxx: /bin/sh^M: bad interpreter: No such file or directory
- windows和linux下使用命令查找端口对应的进程pid并杀死进程
- shell脚本:/bin/sh^M: bad interpreter: No such file or directory
- linux 用notepad++编写shell脚本出现/bin/sh^M: bad interpreter: 没有那个文件或目录l的解决方案
- shell脚本报错问题: -bash: ./test.sh: /bin/sh^M: bad interpreter: No such file or directory
- Shell脚本报错:-bash: ./switch.sh: /bin/bash^M: bad interpreter: No such file or directory
- shell脚本报错:-bash: xxx: /bin/sh^M: bad interpreter: No such file or directory
- 笔记:Shell脚本文件报错:-bash: ./xxx.sh: /bin/bash^M: bad interpreter: No such file or directory
- 执行shell脚本报错:bin/sh^M: bad interpreter: No such file or directory
- shell脚本报错:-bash: xxx: /bin/sh^M: bad interpreter: No such file or directory
- shell脚本异常:/bin/sh^M:bad interpreter: No such file or directory
- shell 编程8 获取 java程序的pid 杀死pid 对应的进程