expect - 如何防止期望忽略新行?
问题描述
在我当前的草稿脚本中,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
解决方案
推荐阅读
- reactjs - 无法预览/下载大于 1.5 MB 的文件
- python - 按字母顺序显示列表
- java - 如何从 Hibernate 配置工具中修复“读取数据库架构时出现问题”
- opencv - 如何校准围绕一个圆圈设置的 4 个摄像头?
- r - 表达式失败时使用 `tryCatch` 并打印错误消息
- oauth-2.0 - 订阅资源时使用 Oauth 的 Exchange Webservice 引发错误
- r - 如何在 R 中使用 RPostgreSQL 在 INSERT 语句中获取自动生成的键
- asp.net-core - 服务器端 Blazor 身份验证
- java - 基于列表的 Java 8 Stream 操作
- performance - 使用/在 Google Apps 脚本中搜索大型 Google 表格中的行的最快方法