0
我想远程登录到远程服务器并尝试获取响应。在python中使用telnet.expect的问题2.7
我之前使用telnet.read_until
来匹配是否出现prompt/pattern,但是即使没有匹配,read_until也会返回所有内容。我想用telnet.expect
,但我得到的错误
下面是代码
com = re.compile("\#") # is the prompt
tn.write("somecommand" + "\n")
res = tn.expect(com, 10)
错误,我得到的是
File "reg.txt", line 23, in login
res = tn.expect(com, 10)
File "C:\Python27\lib\telnetlib.py", line 593, in expect
list = list[:]
TypeError: '_sre.SRE_Pattern' object is not subscriptable
谢谢。它的工作 – Nitesh