pexpect 解析路由器输出
我有几条 pexpect 线路可以登录到 cisco 路由器,并发出 show arp 命令。然后我退出路由器,将数据存储到变量 myARP (myARP=child.before)
当我尝试循环对象时(对于 myARP 中的行: print(lines),信息每行显示 1 个字符< br> 我
我
k
等
哈
我
s
抱歉,这可能是一个非常基本的问题,但是如果我手动发出命令,为什么我不能按显示的方式显示?这与 telnet 连接的流特性有关吗?这怎么解决???
I've got a couple of pexpect lines to log onto a cisco router, and issue the show arp command. I then exit the router, having stored the data into the variable myARP (myARP=child.before)
When I then try and loop over the object (for lines in myARP: print(lines), the info is displayed 1 character per line
l
i
k
e
t
h
i
s
Apologies as this is probably a very basic question, but why can't I display as it is shown if I issue the command manually? Is it to do with the streaming nature of the telnet connection? How can this be resolved???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确定已修复 - 我认为是由于 pexpects 处理行结尾(/n/r)。阅读 Noahs 使用文档以获取更多信息
OK fixed - due to pexpects handling of line endings (/n/r) I think. Read Noahs usage docs for more info