所以我正在尝试Python文档中给出的这个非常简单的例子:
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()
我的问题是它在read_all()结束时停滞了... 它不会打印任何东西。我以前从未使用过这个模块,所以我正在尝试让这个非常基本的示例工作才能继续。顺便说一句,我正在使用Python 2.4。谢谢。