help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] What causes while-read loop to terminate at round 1 when


From: Pierre Gaston
Subject: Re: [Help-bash] What causes while-read loop to terminate at round 1 when ssh is used inside the loop?
Date: Sun, 31 May 2015 19:36:47 +0300

On Sun, May 31, 2015 at 6:39 PM, Peng Yu <address@hidden> wrote:

> The following code will only run for the first localhost but not the
> second. Does anybody know what is wrong with it?
>
> #!/usr/bin/env bash
>
> while read -r -d $'\n' h
> do
>   echo "$h"
>   ssh "$h" "last | grep '$USER' | head"
> done < <(printf "%s\n" localhost localhost)
>
> --
> Regards,
> Peng
>
>
ssh is reading all stdin, you can use ssh -n or ssh </dev/null


reply via email to

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