开发者

pexpect parse router output

开发者 https://www.devze.com 2022-12-13 20:14 出处:网络
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)

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 c开发者_StackOverflow社区an this be resolved???


OK fixed - due to pexpects handling of line endings (/n/r) I think. Read Noahs usage docs for more info

0

精彩评论

暂无评论...
验证码 换一张
取 消