Telnet
Billy Ng
evebill8 at hotmail.com
Thu Mar 21 14:33:50 EST 2002
Hi folks,
I am trying to write a telnet client program. Here is the code:
ID = "123445"
PASSWORD = "333"
try:
tn = telnetlib.Telnet(<host>)
tn.read_until("Please enter your id? ")
tn.write(ID+"\n")
tn.read_until("Enter your password? ")
tn.write(PASSWORD+"\n")
print tn.read_all()
tn.close()
except:
tn.close()
print 'connection failed'
tn.close()
It stops after the ID was written. If I use the actual telnet client, it
returns "Enter your password? " after my ID is submitted. why does not
tn.read_until() find the "Enter your password? " string ? Is there any
other way to handle the password prompt?
Thanks in advance!
Billy Ng
More information about the Python-list
mailing list