Search code examples
python-2.7pyserialcisco

echo in console connection


I use pyserial in python to connect to cisco console port:

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

It works good except there is echo in reply. Is there a way to disable it?


Solution

  • Finally i found that cisco is buggy with serial echo switch off. The function doesn't work. Putty manage incoming text row and modify it to make it look as we want to see

    Thus there are two possible solution:

    1. Manage incoming text row as putty does
    2. Use putty-like apps if it is possible