Exscript TimeoutException

时间:2012-09-30 00:08:56

标签: python ssh cisco

所以我终于让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>'

我错过了一些简单的东西吗?只是尝试登录路由器(作为普通用户,非特权模式),运行show version,然后注销。任何帮助,将不胜感激。感谢。

1 个答案:

答案 0 :(得分:2)

看起来您配置的横幅正在弄乱Exscript期望从设备返回的提示。我建议调整Exscript中的协议驱动程序以更好地处理提示,或者确保您的横幅设置正确(或将其全部删除)