Tcl expect中的IF语句

Tcl expect中的IF语句,tcl,expect,Tcl,Expect,我有一个expect脚本作为bash函数的一部分。脚本必须处理以下内容: if [expect "continue?" then { send "y\r"; exp_continue }] else exp_continue 根据登录路由器后的路由器固件,路由器可能会说“继续”,也可能不会说“继续”,然后您需要输入“y”或“n”,前者会落到路由器外壳上 我如何执行以下操作: if [expect "continue?" then { send "y\r"; exp_continue }]

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

if [expect "continue?" then { send "y\r"; exp_continue }]
else exp_continue
  • 根据登录路由器后的路由器固件,路由器可能会说“继续”,也可能不会说“继续”,然后您需要输入“y”或“n”,前者会落到路由器外壳上
我如何执行以下操作:

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

谢谢。

no
bash
tag在这里;这是纯expect。我只包含expect脚本的代码。这是在EOF标记之间,即
函数myFunc(){/usr/bin/expectFYI,您可能想要
详细说明“扩展”?
$foo
是一个可以扩展的东西。
$(foo)
同样。
set timeout 3 # wait 3 seconds for "continue?"
expect {
  "continue?" { send "y\r"; }
  timeout { }
}
set timeout 10 # return to 10-second default