【发布时间】:2018-07-26 20:25:01
【问题描述】:
我正在尝试使用 Expect 脚本从 FW 输出 ARP 表的大小,以便绘制图表。在下面的代码之后,显示到屏幕的输出如下所示:
/usr/bin/expect -f -<< EOD
spawn ssh test@1.2.3.4
sleep 1
expect {
"*word:" {send "password\r"}
}
sleep 1
expect {
"*>" {send "show arp all | match \"total ARP entries in table\"\r"}
}
sleep 1
expect {
"*>" {send "exit\r"}
}
expect eof
EOD
spawn ssh test@1.2.3.4
FW-Active
Password:
Number of failed attempts since last successful login: 0
test@FW-Active(active)> show arp all | match "total ARP entries in table"
total ARP entries in table : 2861
我想要做的是能够只输出表中总 ARP 条目中指示的数值。我假设我需要一些如何做“cut”或“awk”或仅提取数字的东西,但我没有任何运气。非常感谢任何帮助。
【问题讨论】:
-
为什么投反对票?
标签: linux bash shell scripting expect