我试图将一组命令推送到思科设备。最后一个命令显然是"退出"。
如何确定两者之间的差异,因为可以通过eof跟踪它们。
我目前正在使用expect_after/expect_before
来抓住eof
。
这里是虚拟命令集:
!test !test !test !test !test !test !LAST!!!! exit My expect_before statement: expect_before { eof { RGenerateLog "${logdir}sendconfig-error.log" "${logprefix} Connection was interrupted." exit 11 } } SCENARIO 1 (Successful): sw05-00-00-2960.1194.POE#!test sw05-00-00-2960.1194.POE#!test sw05-00-00-2960.1194.POE#!test sw05-00-00-2960.1194.POE#!test sw05-00-00-2960.1194.POE#!test sw05-00-00-2960.1194.POE#!test sw05-00-00-2960.1194.POE#!LAST!!!! sw05-00-00-2960.1194.POE#exit Connection closed by foreign host. Log: 2015-05-27 12:32:13 [cisco.exp]: User=XXXXXXXX; Device=10.218.8.199; Action=config_change - Connection was interrupted. SCENARIO 2 (Interrupted - I've closed the connection explicitly in the firewall): sw05-00-00-2960.1194.POE# sw05-00-00-2960.1194.POE#Connection closed by foreign host. [root@tritone /tritone/system/send-config]# 2015-05-27 12:35:40 [cisco.exp]: User=XXXXXXXX; Device=10.218.8.199; Action=config_change - Connection was interrupted
所以我的问题是,如何成功推送所有命令,我怎么知道?