在控制台连接中回显

echo in console connection

我在 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-- '
>>>

除了有回音外,还不错。有没有办法禁用它?

最后我发现 cisco 有问题,串行回声关闭。该功能不起作用。 Putty 管理传入的文本行并修改它以使其看起来像我们想要看到的那样

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

  1. 像 putty 一样管理传入的文本行
  2. 尽可能使用类似 putty 的应用程序