TCL数据捕获问题 - 期待

时间:2011-10-22 01:51:23

标签: tcl expect

我想知道如何使用TCL获取上一个命令的输出。

我现在有以下结构:

exp_send -i $spawn_id "show port-access supplicant\r"

set buff ""
expect -regexp {".*"}
    expect -regexp ".*#" {send "show port-access supplicant\r"}
expect eof

*此时的命令返回正确的信息,但我不知道如何将其存储到变量中。

我正在阅读expect_out,但我无法使其正常工作!

1 个答案:

答案 0 :(得分:0)

您可以使用expect缓冲区来执行此操作。完成你的2场比赛:

 expect -regexp ".#" {send "show port-access supplicant\r"}
 expect -regexp ".#"; #Match the prompt again after the device output returns

然后尝试:

 puts $expect_out(buffer)
相关问题