hi
i am using a telnet session to simulate an authentication mechanism
USER = "user"
PASSWORD = "password"
try:
telnet = telnetlib.Telne t(HOST)
telnet.set_debu glevel(5)
telnet.read_unt il("login: ")
telnet.write(US ER + "\n")
telnet.read_unt il("Password: ")
telnet.write(PA SSWORD + "\n")
except:
print "failed to telnet"
else:
try:
telnet.write("l s\n")
except:
print "cannot ls"
else:
telnet.write("e xit\n")
print telnet.read_all ()
When i purposely input a wrong password, it "hangs" at the login prompt
waiting for
login and Password. The host i am telnetting to is a unix server.
How can i "exit" this login prompt if the user keys in wrong password
in my script?
i am using a telnet session to simulate an authentication mechanism
USER = "user"
PASSWORD = "password"
try:
telnet = telnetlib.Telne t(HOST)
telnet.set_debu glevel(5)
telnet.read_unt il("login: ")
telnet.write(US ER + "\n")
telnet.read_unt il("Password: ")
telnet.write(PA SSWORD + "\n")
except:
print "failed to telnet"
else:
try:
telnet.write("l s\n")
except:
print "cannot ls"
else:
telnet.write("e xit\n")
print telnet.read_all ()
When i purposely input a wrong password, it "hangs" at the login prompt
waiting for
login and Password. The host i am telnetting to is a unix server.
How can i "exit" this login prompt if the user keys in wrong password
in my script?
Comment