3

I have a bunch of host names in a file. If I use 'read -r' to loop and print the host names, the code works fine:

while read -r host; do echo $host; done < t
ots-cass-prod8.us-east-1
ots-cass2-prod6.us-east-1
ots-cass2-prod7.us-east-1
ots-cass-next-staging5.us-east-1

If I write more logic in the loop, it stops after reading the first line:

while read -r host; do echo $host; ssh $host cmk_admin -r sre-pager; done < t
ots-cass-prod8.us-east-1
OK

"OK" is the expected output of the cmk_admin command.

What is making my loop stop after the first host?

I always used for loop for reading from a text file like above, but trying to up my game based on suggestions I received on SO.

codeforester
  • 39,467
  • 16
  • 112
  • 140

0 Answers0