- 論壇徽章:
- 0
|
本帖最后由 situxiaoquan1 于 2011-05-19 18:33 編輯
我的腳本如下:
#!/usr/bin/expect -f
for {set IP 11} {$IP<=14} {incr i 3}
{
spawn ssh $IP
expect "login*"
send "db2inst1\r"
expect "Password:"
send "db2inst1\r"
expect "*>*"
send "cd /home/db2inst1/weihu/activemobile/sorting\r"
expect "*>*"
send "rm 1.txt\r"
expect "*>*"
send "exit\n"
expect eof
}
目前只是登陸一臺(tái)主機(jī)可以實(shí)現(xiàn)了,想循環(huán)登陸多臺(tái)執(zhí)行相同命令怎么做?
執(zhí)行腳本報(bào)錯(cuò):
wrong # args: should be "for start test next command"
while executing
"for {set IP 11} {$IP<=14} {incr i 3}"
(file "./test.sh" line 3)
expect循環(huán)應(yīng)該怎么寫呢? |
|