I wrote a script to execute a script on several remote hosts, but somehow during the execution of the local script, ssh can't come back from the remote host, so that causes my local script hanging... I use the below command to do the job in the local script, any idea?
Try to put the script which you want to use in some remote host under the below syntax :
"connection string" !<<EOF
your code
!
This helps the remote host to identify the part of the script its executing remotely.
! you can keep anything but consistency nneds to be maintaned for both the places.
Hi dinjo, that script on that remote host execute a series of other scripts. I can briefly tell you what the remote script do,it run a stop script->show status-> run a start script -> show status. After the second show status done, it will just be hanging there.
If I ssh to that host and run scripts, they runs ok
ssh hostname
cd <path name>
hostname>./stop script
hostname>./show status
hostname>./start script
hostname>./show status
Hi all, I pretty much resolved this, the cause of this problem is:
SSH connects stdin, stdout and stderr of the remote shell to your local terminal, so you can interact with the command that's running on the remote side.
As a side effect, it will keep running until these connections have been closed, which happens only when the remote command and all its children (!) have terminated (because the children, which is what "&" starts, inherit std* from their parent process and keep it open).
So I modify my code to wrap those 4 cmds in script and run it like this