如何使用for循环执行两个变量的语句?

时间:2018-05-14 11:13:38

标签: shell loops scripting

isql  -U username  -P password  -S servername

我想重复执行上述语句五次,每次在for循环中更改用户名和密码。

我该怎么做?

1 个答案:

答案 0 :(得分:0)

当您不在乎ps -ef可以看到您的密码时,您可以

cat credentials.txt
user1 pw1
user2 pw2
user3 pw3
user4 pw4
user5 pw5

while IFS= read -r u p; do
   echo "User $u"
   isql -U "$u" -P "$p" -S servername
done < credentials.txt
相关问题