telnetlib python example
Posted
by
de1337ed
on Stack Overflow
See other posts from Stack Overflow
or by de1337ed
Published on 2012-06-08T16:18:09Z
Indexed on
2012/06/08
16:40 UTC
Read the original article
Hit count: 418
So I'm trying this really simple example given by the python docs:
import getpass
import sys
import telnetlib
HOST = "<HOST_IP>"
user = raw_input("Enter your remote account: ")
password = getpass.getpass()
tn = telnetlib.Telnet(HOST)
tn.read_until("login: ")
tn.write(user + "\n")
if password:
tn.read_until("Password: ")
tn.write(password + "\n")
tn.write("ls\n")
tn.write("exit\n")
print tn.read_all()
My issue is that it hangs at the end of the read_all()... It doesn't print anything out. I've never used this module before so I'm trying to get this really basic example to work before continuing. BTW, I'm using python 2.4 Thank you.
© Stack Overflow or respective owner