【发布时间】:2015-08-27 00:05:47
【问题描述】:
我在使用 Telnet 的 Python 中遇到了一个小问题。我试图通过确定 telnet 连接是否已经登录来启动脚本。我的代码如下所示:
if TLNT.read_until("login: ",2): #if it reads the login prompt:
login(USER,PASS) #runs the function used to login to the system
main() #otherwise will determine system is already logged in and start the main script
这里的问题我不确定这里的格式,因为即使我故意注销了 telnet 系统,脚本也会跳过登录功能,所以我知道它看到了登录提示。如果 telnet 提示停留在“login:”,read_until 会返回什么?
【问题讨论】:
-
问题是什么?
-
我刚刚更新了问题以提供更多信息