I am trying to telnet into a cisco ios-xr router and gather command output.
I have tested that the below code successfully connects to the router and executes the command, however it seems that neither print tn.read_all()
nor tn.read_very_eager()
works. They do not print anything. Am I missing anything obvious here?
#!/usr/bin/env python
import sys
import telnetlib
import time
HOST = "10.62.53.34"
PORT = "17006"
user = "cisco"
password = "cisco"
tn = telnetlib.Telnet(HOST,PORT)
print "Telnetting to", HOST, "@",PORT
tn.write("\n")
tn.write(user + "\n")
tn.write(password + "\n")
#print("I am in")
tn.write("show runn\n")
tn.write("exit \n")
print tn.read_all()
tn.close()