Python Forum
How to read router prompt and use it?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to read router prompt and use it?
#2
Took a while but i could figure it out. Just in case any one is interested.

==== skipped the tn connect part===

Prompt capture to a string:
>>>tn.write(b" " + "\n".encode('ascii'))   ===> Send a simple enter("\n" character and capture the output to get prompt.
>>>str2 = tn.read_eager().decode()   ====> Save prompt to a string.
>>>print(str2)
Output:
[Router]R5-NYC#
Command output capture to a string in case output is multiple lines.
>>>tn.write(b"show clock" + "\n".encode('ascii'))
>>>str2 = tn.read_very_eager().decode()
>>>print(str2)
Output:
show clock Wed May 22 07:16:09 2019 CST [Router]R5-NYC#
tn.read_eager() ===> Kinda returns line by line output but very inconsistent and can be saved to a string.
tn.read_very_eager() === > Returned the entire output(including multiple lines) and can be saved to a string.
Reply


Messages In This Thread
How to read router prompt and use it? - by simbha - May-06-2019, 03:08 AM
RE: How to read router prompt and use it? - by simbha - May-06-2019, 05:56 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with my router. Pocket_Sand 2 2,227 Nov-19-2020, 04:06 PM
Last Post: Pocket_Sand
  Acces Wifi router and scan all the available networks through router jenkins43 3 2,779 Mar-21-2020, 09:35 PM
Last Post: jenkins43
  GNS3 telnet from bash terminal to virtual cisco router marienbad 2 3,734 Feb-24-2019, 07:55 AM
Last Post: marienbad
  Python module for Router configuration parsing anna 0 3,640 Mar-08-2018, 06:02 PM
Last Post: anna
  scapy ssh connection my network sniffing from my router Boss 1 6,199 Feb-13-2017, 07:04 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020