ktbyers / netmiko

Multi-vendor library to simplify Paramiko SSH connections to network devices
MIT License
3.63k stars 1.31k forks source link

Add code 'ESC[c' into method 'strip_ansi_escape_codes' #3453

Closed max-dw-i closed 4 months ago

max-dw-i commented 4 months ago

Some 'MikroTik' devices add ANSI escape codes 'ESC[c' to the end of the output when in 'safe-mode'

ktbyers commented 4 months ago

@max-dw-i Can you show me an output capture with this character sequence? I am not seeing/finding any references to ESC[c looking at ANSI reference codes?

max-dw-i commented 4 months ago

Yeah, I couldn't find either but as far as I understand there might be not typical codes. Here is an output example:

  1. We send \u0018 (ctrl-x) to enter the safe-mode via send_command_timing:
    [Safe Mode taken]
    [user@HOSTNAME] <SAFE>
  2. Then run any command:
    
    /system identity print

name: HOSTNAME \x1b[9999B[user@HOSTNAME] \x1b[c

ktbyers commented 4 months ago

Looks like it is probably:

Device Status
The following codes are used for reporting terminal/display settings, and vary depending on the implementation:
Query Device Code   <ESC>[c
Requests a Report Device Code response from the device.

From here:

https://www2.ccs.neu.edu/research/gpc/VonaUtils/vona/terminal/vtansi.htm

ktbyers commented 4 months ago

Superceded by:

https://github.com/ktbyers/netmiko/pull/3457