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

관련 정보