SCO 5.0.5 (i686-pc-sco3.2v5.0.5), scp and the -n option

Aran Cox acox at cv.telegroup.com
Wed Feb 7 10:19:53 EST 2001


On Mon, Feb 05, 2001 at 06:13:21PM -0600, Aran Cox wrote:
> 
> The real question (for me) here is in what circumstances do I need to
> use -n?  I would swear that in the past, I have needed -n to keep
> shell scripts from hanging on invocations of rsh/rcmd.  Now, I can't
> duplicate that to save me. (Either with rsh/rcmd or ssh.)  It appears
> that I don't even need -n to get X applications to work correctly.  If
> it weren't for the problems with scp hanging around I would just drop
> the -n and forget about USE_PIPE entirely, but -n ought to
> work. However, since I can't seem to find a concrete use for the
> option, that point may be moot. 
> 

Ok, I went out and answered my own question.  If you write a script like
this:  

while read host; do
[rs]sh $host ls -ld .
done

And pass a list of hosts via stdin, only the first host gets
[rs]sh run on it.  Then the script just exits.  [rs]sh sucks up
the rest of stdin, unless you prevent it from doing so with the
-n option.  

I don't quite understand why ssh or rsh would read stdin until
it's empty without the executed program on the other end 
requesting anything of stdin.  Would doing it otherwise have 
been needlessly complex?  Or was that just the behaviour of
rsh and hence the behaviour of ssh?

Aran





More information about the openssh-unix-dev mailing list