bug-bash
[Top][All Lists]
Advanced

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

Re: && operator prevents backgrounding over ssh


From: Bob Proulx
Subject: Re: && operator prevents backgrounding over ssh
Date: Thu, 26 Sep 2013 22:10:41 -0600
User-agent: Mutt/1.5.21 (2010-09-15)

Hinrik Örn Sigurðsson wrote:
> Bob Proulx wrote:
> > Just a reminder that ssh reads from stdin unless explicitly told to
> > avoid reading from stdin.  If stdin isn't going to be used then the -n
> > option should be used.
> > [...]
> > Regardless of the resolution of the above question about bash the
> > usage of ssh in the above should use 'ssh -n'.
> 
> I'm not sure how that is helpful. 'ssh -n' closes stdin prematurely,
> which means that any error from the first command ("cd /tmp") will not
> be propagated to the originating host, e.g. when the directory doesn't
> exist.

Any errors would be reported to stderr.  Any other output would to to
stdout.  Closing stdin has no affect on either stderr or stdout.

In order to connect stdin up to the remote command ssh needs to
actively read any input and then write it off to the remote process
over the socket connection.  Here is an illustration of the difference.

  $ echo foo | { ssh localhost echo bar ; cat ;}
  bar

Where did "foo" go?  It was eaten by ssh and then lost when ssh exited.

  $ echo foo | { ssh -n localhost echo bar ; cat ;}
  bar
  foo

There it is.  Now with -n ssh did not consume it.  That left it for
the next process to consume.

Bob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]