Bash while read loop breaking early [duplicate]

Chris is correct. The source of the loop breaking was SSH using stdin, however guns is correct in is usage of a looping methodology.

If you are looping through input (a file with a list of hostnames for example), and calling SSH, you need to pass the -n parameter, otherwise your loop based on input will fail.

while read host; do
  ssh -n $host "remote command" >> output.txt
done << host_list_file.txt

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)