Re: How to get ssh to work in a loop

From: Kevin Rodgers (ihs_4664_at_yahoo.com)
Date: 12/02/03


Date: Tue, 02 Dec 2003 09:36:15 -0700


[Please don't top-post.]

Mike Cross wrote:

> The for loop scrambles stdin, which upset, ssh/rsh, I get around ths by
> using while loop:
>
>
> while read line
> do
> ..
> ..
> rsh $line date
> ..
> done < file
>
> works OK

No, it doesn't. The body of the while ... done loop inherits its file
descriptors, and the rsh command still consumes all of the remaining
data in standard input. The way to get around this problem is to
redirect rsh's standard input

        rsh $host ... < /dev/null

or use the command line option provided for this purpose

        rsh -n $host ...

-- 
Kevin Rodgers