2016-06-30 62 views
0

我用pyserial在python连接到思科控制台端口:回声控制台连接

>>> import serial 
>>> console = serial.Serial('COM5') 
>>> console.read(console.inWaiting()) 
'' 
>>> console.write('sh ip inter brie\n') 
17L 
>>> console.read(console.inWaiting()) 
'sh ip inter brie\r\nInterface     IP-Address  OK? Method Statu 
s    Protocol\r\nFastEthernet0    unassigned  YES NVRA 
M up     down \r\nFastEthernet1    unassigned 
YES manual up     down \r\nBRI0      unassign 
ed  YES NVRAM administratively down down \r\nBRI0:1 
unassigned  YES unset administratively down down \r\nBRI0:2 
     unassigned  YES unset administratively down down \r\nFastEtherne 
t2    unassigned  YES unset up     down \r\nFas 
tEthernet3    unassigned  YES unset up     down 
\r\nFastEthernet4    unassigned  YES unset up 
down \r\nFastEthernet5    unassigned  YES unset up 
     down \r\nFastEthernet6    unassigned  YES unset up 
       down \r\nFastEthernet7    unassigned  YES unse 
t up     down \r\n --More-- ' 
>>> 

它的工作原理很好,除了有回复回音。有没有办法禁用它?

+0

你是什么意思*“有回声在回复”*?我能看到的是对你的命令的回应。 – SiHa

+0

我发送命令'sh ip inter brie \ n'并且响应以'sh ip inter brie \ r \ n'开头。没有理由将命令发回给我。我知道可以在telnet中关闭回显,我可以在控制台连接中查看是否有可能 – Ivan

回答

0

最后我发现cisco是串行回声关闭的车。该功能不起作用。腻子管理传入文本行,并修改它,使它看起来像我们希望看到

因此,有两种可能的解决方案:

  1. 管理传入的文本行作为腻子
  2. 使用腻子样的应用程序,如果这是可能的