![无法远程运行 bash 脚本 太多)的](https://linux22.com/image/159107/%E6%97%A0%E6%B3%95%E8%BF%9C%E7%A8%8B%E8%BF%90%E8%A1%8C%20bash%20%E8%84%9A%E6%9C%AC%20%E5%A4%AA%E5%A4%9A%EF%BC%89%E7%9A%84.png)
经过一番研究:
我想出了一个脚本,可以登录到远程服务器,然后登录到 telnet 服务器(从远程服务器):
脚本文件
cat run_on_remote.sh | sshpass -p "$PASS" ssh -t -t -o StrictHostKeyChecking=no host@serv
run_on_remote.sh:
echo "[REMOTE] Logged into remote. Current working directory `pwd`"
echo "[REMOTE] Moving deployment to /some/dir"
mv "deployment.rar" "/some/dir"
(
echo open "localhost 50008"
sleep 2
echo "user"
sleep 2
echo "pass"
sleep 2
echo "ls -la | grep deployment-name"
sleep 2
echo "undeploy deployment-name"
sleep 5
echo "deploy deployment-name"
sleep 5
echo "Redeployed adapter"
echo "exit"
) | telnet
echo "Finishing SSH session"
exit
但我收到以下错误:
) | telnet
Too many )'s.
如果我将脚本上传到远程服务器,它就会按预期工作。为什么?