Bash scripting - Remotely ran commands break while loop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



I have two CentOS5 systems server1 and server2. There is user peter on
server1 who can ssh to server2 using public ssh keys and no password is
needed.

What I noticed is that running remote ssh commands in bash script breaks
while loops.

======
#!/bin/sh
for i in server2 server2; do
     echo "--> Start"
     ssh peter@$i ls
     echo "--> END"
done

echo " server2
server2" | \
while read confLine; do
     echo "--> $confLine"
     ssh peter@$confLine ls
     echo "--> END $confLine"
done
====

The "for" loop in the script above will run twice but the "while" loop
below it will run only once.

This is very simple to test and I've tried it on different systems
including CentOS6 and OpenSolaris with the same result.

Any idea what would cause the ssh command to break the while loop?

Thanks
Peter
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos


[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux