【发布时间】:2014-11-10 02:58:58
【问题描述】:
我已经搜索过这个,但没有找到真正适合我的答案。
我想将通过 expect 发送的命令的输出设置为变量,我将使用 TcL 对其进行解析。这将主要用于未安装 TcL 的设备。防火墙、路由器和交换机等。
类似这样的:
send "show interface status"
#output of show command on device
Port Name Status Vlan Duplex Speed Type
Gi1/1 trunk to switch notconnect 100 auto auto 10/100/1000-TX
Gi1/2 this is a test por notconnect 100 auto auto 10/100/1000-TX
Gi1/3 notconnect routed auto auto 10/100/1000-TX
Gi1/4 notconnect 400 auto auto 10/100/1000-TX
我想让变量成为一个列表,如果它有 TcL,我通常会在设备上使用它:
set showInterface [split [exec "show interface status"] \n]
【问题讨论】: