Package: rancid
Severity: normal
Version: 3.13-1
X-Debbugs-Cc: Tollef Fog Heen <[email protected]>
I have a couple of routeros devices where rancid fails to work correctly
on them, since even though it logs in with +ct200w, routeros seems to
send a bunch of escapes. The last couple of lines of the .raw file
reads like:
^M^M^M^[[9999B[admin@vormioox] > q^M[admin@vormioox] > q^[[Ku^M[admin@vormioox]
> qu^[[Ki^M[admin@vormioox] > qui^[[Kt^M[admin@vormioox] > quit^[[K^M
^Minterrupted
^[7^[[;54r^[8Connection to vormioox.err.no closed.^M^M
rancid then outputs:
vormioox.err.no.raw: missed cmd(s): all commands
vormioox.err.no.raw: End of run not found
vormioox.err.no.raw: clean_run is false
vormioox.err.no.raw: found_end is false
Something like this seems to fix it for me, and ought not to break it
for anyone else. (Diff might be slightly off; I had to hand-hack it,
but I can provide a clean one if necessary.)
# diff -u routeros.pm~ routeros.pm
--- routeros.pm~ 2023-03-11 09:08:12.729340483 +0100
+++ routeros.pm 2023-03-12 05:24:30.074961827 +0100
TOP: while (<$INPUT>) {
tr/\015//d;
- if (/[>#]\s*quit$/) {
+ if (/[>#]\s*quit(?:\x{1b}\[K)?/m) {
$clean_run=1;
last;
}
@@ -98,7 +99,7 @@
$clean_run = 0;
last;
}
- while (/\s*($cmds_regexp)\s*$/) {
+ while (/\s*($cmds_regexp)\s*(?:\x{1b}\[K)?$/) {
$cmd = $1;
if (!defined($prompt)) {
$prompt = "\] > "; # crude but effective
@@ -167,7 +171,7 @@
while (<$INPUT>) {
tr/\015//d;
last if (/$prompt/);
- next if (/^(\s*|\s*$cmd\s*)$/);
+ next if (/^(\s*|\s*$cmd\s*)(?:\x{1b}\[K)?$/);
return(1) if (/(bad command name )/);
s/^\s+//g;
@@ -187,7 +191,7 @@
while (<$INPUT>) {
tr/\015//d;
last if (/$prompt/);
- next if (/^(\s*|\s*$cmd\s*)$/);
+ next if (/^(\s*|\s*$cmd\s*)(?:\x{1b}\[K)?$/);
return(1) if (/(bad command name )/);
s/^\s+//g;
@@ -204,8 +208,9 @@
while (<$INPUT>) {
tr/\015//d;
if (/$prompt/) { $found_end=1; $clean_run=1; return 0};
- next if(/^(\s*|\s*$cmd\s*)$/);
+ next if(/^(\s*|\s*$cmd\s*)(?:\x{1b}\[K)?$/);
next if(/^#/);
return(1) if /(bad command name )/;
s/^\s+//g;
--
Tollef Fog Heen
UNIX is user friendly, it's just picky about who its friends are