【发布时间】:2023-03-14 02:04:01
【问题描述】:
我编写了一个脚本来捕获 Cisco Nexus 设备上的连接端口计数,如下所示:
指挥思科:
example01#sh interface status | i connected | exclude Po | exclude Lo|count
13
example01#
脚本部分:
send "sh interface status \| i connected \| exclude Po \| exclude Lo \| count\r"
expect -re {([0-9]+)}
set COUNT "$expect_out(0,string)"
puts "$COUNT\r"
问题是设备的主机名也有数字,比如 01。当我保存输出时,我看到的只是“01”,而不是我期望的正确输出(这种情况下是 13)。
【问题讨论】: