JEHERUL wrote:
Dear All
I am trying to telnet to a Cisco router . Following is my code .
#code router.py
import getpass
import sys
import telnetlib
HOST = "router address" # router address is ommitted for
security reason
user = raw_input("Username : ")
password = getpass.getpass()
tn = telnetlib.Telnet(HOST)
tn.read_until("Username: ")
tn.write(user + "\n")
tn.read_until("Password: ")
tn.write(password + "\n")
tn.read_until("I>")
tn.write("sh int f0/0")
print "Just to check"
print tn.read_all()
print "after read"
tn.write("exit\n")
But when I execute the program I got the following error .
Traceback (most recent call last):
File "router.py", line 23, in ?
print tn.read_all()
File "/usr/lib/python2.4/telnetlib.py", line 330, in read_all
self.fill_rawq()
File "/usr/lib/python2.4/telnetlib.py", line 521, in fill_rawq
buf = self.sock.recv(50)
Please help me .
Regards
--
Jeherul Islam
Indian Institute of Information Technology and Management .
Gwalior (MP)
Hi,
Your error trace is incomplete it's missing the exception. It would be
better if you provide it.
JM
--
http://mail.python.org/mailman/listinfo/python-list