Discussion:
[rancid] custom command, need help with pipe
Deny IP Any Any
2011-01-10 15:52:25 UTC
Permalink
Hello. I'm trying to write a custom command to store the output of
'show int status | inc trunk'. It seems to work OK without the pipe
and "inc trunk", so I assume something is eating the pipe (|)
character. How should I escape it properly?

This is what I have, and it isn't working (missed cmd(s)).. can
somebody point me in the right direction?


{'show int status | inc trunk' => 'ShowIntTrunk'},


sub ShowIntTrunk {
print STDERR " In ShowIntTrunk: $_" if ($debug);
my($lines) = 0;

while (<INPUT>) {
tr/\015//d;
last if (/^$prompt/);
next if (/^(\s*|\s*$cmd\s*)$/);
return(1) if /Line has invalid autocommand /;
return(1) if /(Invalid input detected|Type help or )/;
return(-1) if (/command authorization failed/i);
# the pager can not be disabled per-session on the PIX
if (/^(<-+ More -+>)/) {
my($len) = length($1);
s/^$1\s{$len}//;
}

/^No matching debug flags set$/ && next;
ProcessHistory("COMMENTS","keysort","J1","!TRUNK: $_");
$lines++;
}
if ($lines) {
ProcessHistory("COMMENTS","keysort","J0","!\n");
}
return(0);
}
--
deny ip any any (4393649193 matches)
john heasley
2011-01-10 17:49:50 UTC
Permalink
Post by Deny IP Any Any
Hello. I'm trying to write a custom command to store the output of
'show int status | inc trunk'. It seems to work OK without the pipe
and "inc trunk", so I assume something is eating the pipe (|)
character. How should I escape it properly?
This is what I have, and it isn't working (missed cmd(s)).. can
somebody point me in the right direction?
my guess is that maybe this botched in the main loop regex. I'd just
remove it and do the filtering inside the ShowIntTrunk() func.
Post by Deny IP Any Any
{'show int status | inc trunk' => 'ShowIntTrunk'},
sub ShowIntTrunk {
print STDERR " In ShowIntTrunk: $_" if ($debug);
my($lines) = 0;
while (<INPUT>) {
tr/\015//d;
last if (/^$prompt/);
next if (/^(\s*|\s*$cmd\s*)$/);
return(1) if /Line has invalid autocommand /;
return(1) if /(Invalid input detected|Type help or )/;
return(-1) if (/command authorization failed/i);
# the pager can not be disabled per-session on the PIX
if (/^(<-+ More -+>)/) {
my($len) = length($1);
s/^$1\s{$len}//;
}
/^No matching debug flags set$/ && next;
ProcessHistory("COMMENTS","keysort","J1","!TRUNK: $_");
$lines++;
}
if ($lines) {
ProcessHistory("COMMENTS","keysort","J0","!\n");
}
return(0);
}
--
deny ip any any (4393649193 matches)
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
Continue reading on narkive:
Loading...