我正在尝试运行一个脚本来显示所有配置并将它们写入瞻博网络和 CISCO 路由器的文件中。到目前为止,CISCO 脚本正在正常工作,但问题在于瞻博网络路由器。
for ii in JUNIPER:
print ii
cmd2 = 'show configuration | display set'
conn.connect(ii)
conn.login(account1)
conn.execute(cmd2)
print conn.response
#filerouter = open(ii, "w")
#filerouter.write(conn.response)
#filerouter.close()
获取要查询的设备列表后,我运行它,但它卡住了,好像缓冲区有限制...... -
如果我尝试执行不同的命令:
("show configuration | display set | match destination ")
-- 我将输出写入文件或屏幕。
C:\Python27>python.exe C:\User\suserrr\Downloads\shrun.py
'clear' is not recognized as an internal or external command,
operable program or batch file.
Generating configs for ROUTER: R1.test.site
Generating connect for ROUTER: R2.test.site
==============
===========
routername
Traceback (most recent call last):
File "C:\Users\userrr\Downloads\shrun.py", line 40, in <module>
conn.execute(cmd2)
File "C:\Python27\lib\site-packages\exscript-2.1.440-py2.7.egg\Exscript\protocols\Protocol.py", line 900, in execute
return self.expect_prompt()
File "C:\Python27\lib\site-packages\exscript-2.1.440-py2.7.egg\Exscript\protocols\Protocol.py", line 999, in expect_prompt
result = self.expect(self.get_prompt())
File "C:\Python27\lib\site-packages\exscript-2.1.440-py2.7.egg\Exscript\protocols\Protocol.py", line 980, in expect
result = self._expect(prompt)
File "C:\Python27\lib\site-packages\exscript-2.1.440-py2.7.egg\Exscript\protocols\Protocol.py", line 956, in _expect
result = self._domatch(to_regexs(prompt), True)
File "C:\Python27\lib\site-packages\exscript-2.1.440-py2.7.egg\Exscript\protocols\SSH2.py", line 329, in _domatch
if not self._fill_buffer():
File "C:\Python27\lib\site-packages\exscript-2.1.440-py2.7.egg\Exscript\protocols\SSH2.py", line 303, in _fill_buffer
raise TimeoutException(error)
Exscript.protocols.Exception.TimeoutException: Timeout while waiting for response from device
=========== ==== 问题 - 我如何让脚本运行并提供命令的输出:show configuration | display set
第二张图片显示了我得到的错误,但如果我将命令更改为:show configuration | display set | match description
我获取要求的信息。我是否想在模块中添加一些内容以便 exscript/python 避免超时?