ssh host echo bla | echo bla

Michael Tokarev mjt at tls.msk.ru
Tue Dec 18 10:37:53 EST 2001


Nicolas Williams wrote:
[]
>  - with -1, if stdout is a dead pipe, then ssh trie to open /dev/tty?
>  - with -2, if stdout is a dead pipe, then ssh exits?
> 
> Why should one behaviour be correct and the other not?
> 
> I mean, if you've got a broken pipe, print a message to stderr about it,
> and if that's broken too, oh well. Either way exit.
> 
> So I would say that the -1 behaviour is forgiving, but the -2 behaviour
> is correct.

Them aren't consistent at the end.  And -2 doesn't print the error
message (and not tries to logon to remote host).  Can't say about
logging in to remote, but the error message should be printed in
both cases (stderr isn't closed, it's ssh's stdout that's closed).
And both should exit with non-zero return code (imho):

 $ (ssh -1 localhost echo mmm; echo $? >&2) | true
 mjt at localhost's password: 
 Write failed flushing stdout buffer.
 write stdout: Broken pipe
 255
 $ (ssh localhost echo mmm; echo $? >&2) | true
 mjt at localhost's password: 
 0
 $ _

The 255 and 0 are the return codes.  Note that in this case, connection
attempt WAS made by both ssh's (note the passwd prompt).  (openssh-2.2.9p2).

Regards,
 Michael.



More information about the openssh-unix-dev mailing list