[rancid] custom command, need help with pipe

john heasley heas at shrubbery.net
Mon Jan 10 17:49:50 UTC 2011


Mon, Jan 10, 2011 at 10:52:25AM -0500, 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.
> 
> {'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
> Rancid-discuss at shrubbery.net
> http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss


More information about the Rancid-discuss mailing list