do while ループを使用する Bash スクリプトは無限に実行されます。

do while ループを使用する Bash スクリプトは無限に実行されます。

以下はbashスクリプトです。無限に実行されます。私はserver.txtファイルに保存されている10個のサーバーに対してのみこのスクリプトを実行したいと思います。助けてください

#!/bin/bash
user=$1
pass=$2

if [ "$#" -ne 2 ];then
echo "Please run the script with userid and password as arguments"
fi

cat servers.txt | while read host

do {

 ./sandy_try.sh $user $host $pass


} < /dev/null; done

ベストアンサー1

私は次のことをします。

while read line; do
    echo do something fancy with "$line"
done < servers.txt

おすすめ記事