如何将命令错误输出发送到TCL中的变量(错误可能发生在第n位之后)?
我使用以下TCL脚本在路由器中配置VLAN如何将命令错误输出发送到TCL中的变量(错误可能发生在第n位之后)?,tcl,expect,Tcl,Expect,我使用以下TCL脚本在路由器中配置VLAN send "interface vlan 1\r" expect "*#" send "commit\r" expect "*#" send "interface vlan 2\r" expect "*#" send "commit\r" expect "*#" . . send "interface vlan <n>\r" expect "*#" send "commit\r" expect "*#" 发送“接口vlan 1\r” 期望
send "interface vlan 1\r"
expect "*#"
send "commit\r"
expect "*#"
send "interface vlan 2\r"
expect "*#"
send "commit\r"
expect "*#"
.
.
send "interface vlan <n>\r"
expect "*#"
send "commit\r"
expect "*#"
发送“接口vlan 1\r”
期望“*#”
发送“提交”\r\n
期望“*#”
发送“接口vlan 2\r”
期望“*#”
发送“提交”\r\n
期望“*#”
.
.
发送“接口vlan\r”
期望“*#”
发送“提交”\r\n
期望“*#”
一段时间后,一旦达到可在此路由器上配置的VLAN的最大数量,它将通过一个错误。它可以位于VLAN 16、VLAN 32或VLAN 48
我想将此错误输出捕获到一个变量中,以便进一步处理。有没有办法将此错误输出捕获到$expect\u out(缓冲区)
?请帮我解决这个问题
谢谢,
Balu P.
您不能说错误是否发生在
接口
命令或提交
上。比如:
for {set i 1} {$i <= 48} {incr i} {
send "interface vlan $i\r"
expect {
"*ERROR*" {
# specify the error string you want to catch instead of "ERROR"
set err $expect_out(buffer)
break
}
"*#" {
send "commit\r"
expect "*#"
}
}
}
{set i 1}{$i的