Re: Bash scripting - Remotely ran commands break while loop

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



On Wed, Feb 01, 2012 at 01:07:31PM -0800, Peter Blajev wrote:
> 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.

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

"ssh" is reading from stdin and passing the data over to the remote
machine.  You can test this with
  ssh peter@$confLine 'read x ; echo we got $x'

To stop it doing this, use the "-n" flag
  ssh -n peter@$confLine ls

-- 

rgds
Stephen
_______________________________________________
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