Discussion:
[rancid] custom command table and grep
Khurram Khan
2013-03-06 08:24:49 UTC
Permalink
Hello All,

I've got a device that I'm building a custom command table for and trying
to grep out a ssh key that I don't want displayed in the configuration.
When running the command from cli on the device, the syntax looks like:

show configuration | grep -v "ssh "

and the cli command does what it's supposed to.

How do I incorporate the start/end quotes in the command table? I've tried
a couple of variations and the script errors out.

@commandtable = (
{'no timestamps' => 'DoNothing' },
{'show configuration | grep -v "ssh "' => 'WriteTerm' },
);

Thanks in advance!
heasley
2013-03-06 18:32:40 UTC
Permalink
Post by Khurram Khan
Hello All,
I've got a device that I'm building a custom command table for and trying
to grep out a ssh key that I don't want displayed in the configuration.
show configuration | grep -v "ssh "
and the cli command does what it's supposed to.
How do I incorporate the start/end quotes in the command table? I've tried
a couple of variations and the script errors out.
@commandtable = (
{'no timestamps' => 'DoNothing' },
{'show configuration | grep -v "ssh "' => 'WriteTerm' },
);
dont do it that way. add your filter in WriteTerm, if you must.
Post by Khurram Khan
Thanks in advance!
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
Khurram Khan
2013-03-06 18:39:46 UTC
Permalink
I wrote a filter, and perhaps I'm not doing it right but the one I've got
in the script is:

if (/\s+ssh key \S / && filter_pwds >= 1) {
ProcessHistory("ADMIN","","","#ssh key <removed>\n");
next;
}

the configuration from cli looks like this:

ssh key
+A0xxl6l15l6s800mta4qnknyalr1je5u8s76zlcx3myxhbnhe5v5j0yv721a4x2len02e5hs7wykq0s2u9cemrh4vxfk3e78aegfu9rht1ktf9m7zrnn1p3815woa30nduz2febcn5dxnoa2157i8vvkzys843dhzkexqj5atn2fj6njnnplwoc0li9in2lzgi6m2bue2rckfxrvn0dl92m6k0szbb3rpq8evwyrpkm27awx9clm2rmr0w5zy6rf9bshz3kqsu2vlj9kit30riazgllauvx2zcpfgieuig9e1g8fs73staweu3a0lnaj7j4aem2w58mqw27gby32c0v1rpecks841obelgd5zhwij37jx2qghay3s61nd7ysf8fhqw62i05s1jq85yo009hs7230audxy0wqbe63nb0g601cym5s7q9srpo151dgm4qehv3k1b99cz2amtzwz1y85fbxoj0ahm0jxp01p9xdudo1qgot3l82qcwb2fplrrw2dojjz3bpe5xfhh19lg2xcwnebyvz8jh0489wb5sjd7551ijhpzue3u4a40uqam01a9lhte0nrscnemcj1jc1h4hb8rlapljk3h6gqbdcqg60r0amxoqp67q1912v3nyl556pue015a4euijgbaxw3sf6k05w19gk10xlxaek9rgtbj3nf5mwnmzlfjh1hs9alqm43izz1eei4zk8ind4x2alhshhu2ripv25oa98g7pwbm22cj3kny7ehjib2td35qksn79er1whrzb4pcqqqe3el0fwkke4o2t0dvwhrrsewhlr3lxrw91idqr11
len 488 type v2-rsa
Post by heasley
Post by Khurram Khan
Hello All,
I've got a device that I'm building a custom command table for and trying
to grep out a ssh key that I don't want displayed in the configuration.
show configuration | grep -v "ssh "
and the cli command does what it's supposed to.
How do I incorporate the start/end quotes in the command table? I've
tried
Post by Khurram Khan
a couple of variations and the script errors out.
@commandtable = (
{'no timestamps' => 'DoNothing' },
{'show configuration | grep -v "ssh "' => 'WriteTerm' },
);
dont do it that way. add your filter in WriteTerm, if you must.
Post by Khurram Khan
Thanks in advance!
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
--
- kk
Loading...