I collect some data from users' routers, connecting via SSH, reading from pexpect. before.
Having trouble on only one router, that his Pexpect output is out of sync. I have 16 parameters that need collecting data from the router.
Solution from @user145078:
session.send(cmd)
index = session.expect([cmd, pexpect.TIMEOUT], 1)
session.send('\n')
index = session.expect([whatever you expect])
Worked a little bit, from 16 parameters, 14 are now in sync, and 2 of them aren't.
I don't know why those 2 parameters are still out of sync. Data is gathered in alphabetical order, meaning if I have commands for 'router_speed', 'signal_to_noise_ratio', 'serial', 'device_uptime','attn' they would be gathered in order:
'attn' 'device_uptime' 'router_speed' 'serial' 'SNR'
With the solution I used for this, only 'SNR' and 'attn' parameters are out of sync, with 'SNR'.before outputting last commands output and 'attn'.before outputing welcoming message to router:
Speedport Plus181\r\n \r\n\r\n\r\n\r\nBusyBox v1.15.3 () built-in shell (ash)\r\nEnter 'help' for a list of built-in commands.
Don't know what to do, all those other solutions are a bit complicated to get into my running code.
Sorry for the bad grammar or bad explanation but I need help:D
Well I fixed it, it was a syntax bug/error in the commands for those two parameters.
missing ), unterminated subpattern at position 37
All is fine now.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.