[英]Can`t call command with variable on sh file using ssh
I have the script on centos 7
server for kill process by used id: 我在
centos 7
服务器上具有使用过的id杀死进程的脚本:
#!/bin/sh
echo "killing services..."
kill -9 "$(lsof -t -i:3011)"
kill -9 "$(lsof -t -i:4011)"
Above script works fine when it is called from the server. 从服务器调用上述脚本时,它可以正常工作。
But my goal calls this file using ssh
from my local machine like: 但是我的目标是使用本地计算机中的
ssh
调用此文件,例如:
ssh xxx@xxx.x "sh ~/stopServices.sh"
But I git this error: 但我git这个错误:
killing services...
/home/system/gepick-dev/stopDevServices.sh: line 5: lsof: command not found
/home/system/gepick-dev/stopDevServices.sh: line 5: kill: `': not a pid or valid job spec
/home/system/gepick-dev/stopDevServices.sh: line 6: lsof: command not found
/home/system/gepick-dev/stopDevServices.sh: line 6: kill: `': not a pid or valid job spec
you need to install lsof on the remote server. 您需要在远程服务器上安装lsof。
or try to add the full path like /usr/sbin/lsof to your script or configure your PATH in the remote server if the binary is already installed 或尝试将完整的路径(例如/ usr / sbin / lsof)添加到脚本中,或者如果已安装二进制文件,则在远程服务器中配置PATH
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.