问题原文
原帖链接 · Jesse_Pinkman · CC BY-SA 3.0
I am currently writing a bash script to help me update some servers, so I need to connect there, run yum update -y and then sometimes type in additional commands. I do currently have this set up:
for servers in $devservers
do
ssh $servers 'yum update -y'
done
But the problem is that when I run this, it won't allow me to write some additional commands in case I need to - like when I need to restart certain services. Is there a way to make the script wait for me until I log out of the server?
已采纳解答
原帖链接 · Jakuje · CC BY-SA 3.0
If you need shell access after the yum ends, you need to run a bash or your preferred shell. Also using -t will help you to work properly (allocate remote TTY).
for servers in $devservers
do
ssh -t $servers 'yum update -y;bash'
done
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
