预期的IF声明

时间:2014-05-18 23:11:45

标签: tcl expect

我有一个expect脚本作为bash函数的一部分。该脚本必须处理以下内容:

  • 登录路由器后,根据路由器固件可能会或可能不会说"继续?"然后你需要进入' y'或者' n'前者掉到了路由器的外壳

我如何做以下事情:

if [expect "continue?" then { send "y\r"; exp_continue }]
else exp_continue

感谢。

1 个答案:

答案 0 :(得分:1)

set timeout 3 # wait 3 seconds for "continue?"
expect {
  "continue?" { send "y\r"; }
  timeout { }
}
set timeout 10 # return to 10-second default