[Help-bash] What causes while-read loop to terminate at round 1 when ssh
From:
Peng Yu
Subject:
[Help-bash] What causes while-read loop to terminate at round 1 when ssh is used inside the loop?
Date:
Sun, 31 May 2015 10:39:32 -0500
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