所以我终于让 exscript 正常工作(我认为)。我想测试它,所以我设置了一个我认为应该可以工作的简单 python 脚本:
from Exscript.util.interact import read_login
from Exscript.protocols import SSH2
account = read_login()
conn = SSH2()
conn.connect('router.domain.com')
conn.login(account)
conn.execute('terminal length 0')
conn.execute('show version')
print conn.response
conn.send('exit\r')
conn.close()
我运行脚本并看到以下内容:
kidd@server scripts$ python test1.py
Please enter your user name [kidd]:
Please enter your password:
它在那里停留了大约 20 秒,然后我得到了这个:
Traceback (most recent call last):
File "test1.py", line 7, in <module>
conn.login(account)
File "/usr/lib/python2.7/site-packages/Exscript/protocols/Protocol.py", line 597, in login
self.auto_app_authorize(app_account, flush = flush)
File "/usr/lib/python2.7/site-packages/Exscript/protocols/Protocol.py", line 846, in auto_app_authorize
self.get_driver().auto_authorize(self, account, flush, bailout)
File "/usr/lib/python2.7/site-packages/Exscript/protocols/drivers/one_os.py", line 43, in auto_authorize
conn.app_authorize(account, flush, bailout)
File "/usr/lib/python2.7/site-packages/Exscript/protocols/Protocol.py", line 820, in app_authorize
self._app_authenticate(account, password, flush, bailout)
File "/usr/lib/python2.7/site-packages/Exscript/protocols/Protocol.py", line 690, in _app_authenticate
raise TimeoutException(msg)
Exscript.protocols.Exception.TimeoutException: Buffer: '\rThis is a private system \r\n \r\nrouter>'
我错过了一些简单的东西吗?只是尝试登录到路由器(作为普通用户,非特权模式),运行显示版本,然后注销。任何帮助,将不胜感激。谢谢。