我試圖讓預期腳本能夠工作,並且當我使用-re標誌(用於調用正則表達式解析)時,'超時'關鍵字似乎不再有效。當運行以下腳本時,我收到消息'在第1步超時',然後'開始第2步',然後超時但不打印'在第2步超時'我只是得到一個新提示。超時無法在預期腳本中使用'-re'標誌
想法?
#!/usr/bin/expect --
spawn $env(SHELL)
match_max 100000
set timeout 2
send "echo This will print timed out\r"
expect {
timeout { puts "timed out at step 1" }
"foo " { puts "it said foo at step 1"}
}
puts "Starting test two\r"
send "echo This will not print timed out\r"
expect -re {
timeout { puts "timed out at step 2" ; exit }
"foo " { puts "it said foo at step 2"}
}