while loop to read file ends prematurely

后端 未结 4 1875
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-06 08:29

The eventual goal is to have my bash script execute a command on multiple servers. I almost have it set up. My SSH authentication is working, but this simple while loop is

4条回答
  •  Happy的楠姐
    2021-01-06 09:04

    As the solution specified here use -n option for ssh or open file with a different handle:

    while read -u 4 HOST
      do
        echo $HOST
        ssh $HOST "uname -a"
        ssh $HOST "oslevel -s"
        echo ""
      done 4< hosts.list`
    

提交回复
热议问题