Re: Why stdin is required to be overwritten in SSH?

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

 



On Tue, Oct 18, 2016 at 10:34 AM, Jin Li <lijin.abc@xxxxxxxxx> wrote:
> Could you tell me why `stdin` needs to be overwritten in SSH? Thanks.

Consider this (almost) equivalent simplified script:

while read -r run
do
  ssh localhost date
done < <(seq 10)

What's happening is that the remaining 9 lines are being read by ssh
and sent to the remote server where the "date" command ignores them
and they are discarded (but ssh doesn't know that the remote "date" is
going to do that).  If you replace the "date" with "cat" you can see
this:

$ cat t
while read -r run
do
  cat
done < <(seq 10)

$ bash t
2
3
4
5
6
7
8
9
10

This doesn't happen with a local "date" command because it never reads
its stdin.

When you redirect ssh's stdin to /dev/null the ssh no longer consumes
the output from "seq".  ssh also has a "-n" option that does this.

-- 
Darren Tucker (dtucker at zip.com.au)
GPG key 11EAA6FA / A86E 3E07 5B19 5880 E860  37F4 9357 ECEF 11EA A6FA (new)
    Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@xxxxxxxxxxx
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev



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

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux