在我的预期脚本中,expect_after捕捉到来自BadPromptPassword的超时,但是,我如何返回这是我预期脚本超时的地方?我玩得很期待,但它并没有给我所需要的。。。感谢您的帮助。感谢
spawn telnet 172.27.228.239
expect {
timeout { puts "Timed out waiting for response from telnet ('172.27.228.230',)."; exit 1}
"Password:" { send "labr"; }
"[>#]"
};
send "enr"
expect_after {
timeout {
puts "a default timeout clause for all subsequent expect commands ";
exit 1
}
}
expect "#>"
send "admin"
expect "BadPromptPassword:"
send "labr"
close
wait
这里有一个快速破解
expect_after {
timeout {
puts "timed-out expecting $pattern";
exit 1
}
}
set pattern "#>"
expect $pattern
send "admin"
set pattern "BadPromptPassword:"
expect $pattern
send "labr"