首页 > 解决方案 > 如何防止期望忽略新行?

问题描述

在我当前的草稿脚本中,show命令输出很好,但是一旦我点击“conf”命令,输出就会被压在一起。我该如何解决?

set timeout 20
spawn ssh -l manager 192.168.41.10.10
expect "manager@192.168.10.10's password:"
send "admin\r"
expect "Press any key to continue"
send "j"
log_file hp.log
send "show vlan 10\r"
expect "newsw*"
send "conf\r"
expect "newsw*(config)"
send "\r"
send "vlan 45\r"
expect "newsw*"
send "tagged 3\r"
send "exit\r"
send "exit\r"

这是“conf”部分和相关命令的日志的样子。输出一起运行。你可以在最后看到一段“show vlan 45”。

newswitch# confnewswitch(config)# vlan 45newswitch(vlan-45)# tagged 3newswitch(vlan-45)# exitnewswitch(config)# exitnew$ Status and Counters - VLAN Information - VLAN 45

      VLAN ID : 45
      Name : VLAN45

这是正确/期望的输出。我认为它看起来像这样:

newswitch# 
conf
newswitch(config)# vlan 45
newswitch(vlan-45)# tagged 3
newswitch(vlan-45)# exit
newswitch(config)# exit
newswitch$ show vlan 45 ....and so forth

标签: expect

解决方案


推荐阅读