telnet problem

神父 wxj0302 at gmail.com
Fri Nov 1 15:16:40 CET 2013


hello every expert,
When I use telnetlib to send a command, I meet some troubles, I have read
some documents about telnetlib and modify many times, but the script
doesn't work all the time. I want to know why.
My script is following:
#!/usr/bin/python
#
import telnetlib

t = telnetlib.Telnet()
t.open('192.168.1.1',port=23)
t.set_debuglevel(2)
t.read_until("login: ")
t.write('administrator' + '\r\n')
t.read_until("password: ")
t.write('abc123' + '\r\n')
t.read_until(">$")
t.write('dir' + '\r\n')
t.write('exit' + '\r\n')
print t.read_all()

Thanks and best regards


W
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20131101/d6bc6373/attachment.html>


More information about the Python-list mailing list