This is a follow-up to the following question:
Executing ssh command in a bash shell script within a loop
I am doing a similar job:
while read line
do
ssh -n root@$line 'command'
do something
done
The problem is that I want to execute the “do something” part only when the execution of ‘command’ is complete in the previous ssh line ie I want to wait till the background ssh completes.
I can use sleep, but this does not suit my application. Please guide me.
I don’t want to particularly run ssh in the background. I am only doing this so that my loop runs properly. As given in Executing ssh command in a bash shell script within a loop
if we dont give -n flag, the loop terminates after first ssh command execution.
A little bit of googling help me:
In this way, there is no need of -n flag.
For more details:
http://72.14.189.113/howto/shell/while-ssh/