ssh脚本不会将控制权返回给父脚本 [英] ssh script doesn't return control to the parent script
本文介绍了ssh脚本不会将控制权返回给父脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图通过将其写入 ssh
命令的标准输入中来在远程服务器上执行本地脚本.该脚本可以正常运行,但是 ssh
不会退出:它只是挂起,控件也不会返回到父脚本.
I am trying to execute a local script on the remote server, by writing it to standard input of an ssh
command. The script runs fine, but then ssh
doesn't exit: it just hangs, and control doesn't return to the parent script.
父级外壳:
for HOSTNAME in ${HOSTS} ; do
ssh -t -t $HOSTNAME "bash -s" < ~backup_conf.sh
done
调用脚本:
#!/bin/sh
AGENT_BASE_PATH=/home/lokesh
if [ -d "$AGENT_BASE_PATH/CI/DE_deployment/conf" ]; then
if [ -d "$AGENT_BASE_PATH/CI/temp/conf_bkup" ]; then
rm -rf $AGENT_BASE_PATH/CI/temp/conf_bkup
fi
cp -R $AGENT_BASE_PATH/CI/DE_deployment/conf $AGENT_BASE_PATH/CI/temp/conf_bkup
fi
exit
我已经写了退出",但是控件没有返回到父脚本.它挂在远程服务器上....:(
I have written 'exit' but the control is not returning back to the parent script. It hangs at the remote server.... :(
推荐答案
罪魁祸首是调用代码中的 bash -s
行,该行仍期望输入使用 ctrl-C结束
:
Culprit is bash -s
line in your calling code, which is still expecting input to be ended using ctrl-C
:
尝试以下方法:
for HOSTNAME in ${HOSTS} ; do
ssh -t -t $HOSTNAME "bash ~backup_conf.sh"
done
这篇关于ssh脚本不会将控制权返回给父脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文