11-25-2020 03:25 AM
I've got a couple of expect 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 PrepaidCardStatus???
11-25-2020 06:28 AM
Hello,
can you post the script ? Most likely it is something related to the terminal length. You can try:
expect >
send -- "terminal lengh 0\r"
11-25-2020 07:46 AM - edited 11-25-2020 07:46 AM
Hi there,
I looks like the variable myARP is a string and not a list. When you are trying to print each element with a newline, you are in fact printing each character of the string.
Share your script, we can debug it.
cheers,
Seb.
11-25-2020 01:35 PM - edited 11-25-2020 01:43 PM
As Seb says it looks like it is treating it as a string so try this with your for loop -
for line in myARP.split('\r\n'):
print(line)
basically you are telling it where the separator is for each line through the loop.
Jon
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide