下面是 bash 脚本。它无限执行。我只想为 10 台服务器执行该脚本,我已将其存储在servers.txt 文件中。请帮忙
#!/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