我在python中使用pyserial连接到cisco控制台端口:
>>> 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 :(得分:0)
最后我发现cisco在串口回声关闭的情况下出了问题。该功能不起作用。 Putty管理传入的文本行并对其进行修改以使其看起来像我们想要看到的那样
因此有两种可能的解决方案: