Discussion:
[rancid] JRancid show config | display set
Árni Birgisson
2009-10-29 11:12:44 UTC
Permalink
Hey guys,

I'm interested in adding a command to jrancid - rancid for juniper -
to be able to get the "display set" version of the config.

The command for that is "show configuration | display set".

Has anybody done this?


Digging through the code it seems like adding this command to the
commandtable is failing because of the | (pipe) character.
For example, this line of code:

$cmds_regexp=join("|",@commands);

is joining all the different commands into a string, seperated by the
pipe character.

This variable is then used later is this regexp check

while (/>\s*($cmds_regexp)\s*$/) {

and my command which includes the pipe characters is probably not
behaving correctly in there.


I've tried making some changes to the code to make it work, but i'm
wondering if anybody has found a better solution to this?

-Arni



Arni Birgisson
Network Engineer
FATTOC Iceland
Adalstraeti 6
101 Reykjavik
Iceland
Jeremy Singletary
2009-10-30 02:13:15 UTC
Permalink
Change
$cmds_regexp=join("|",@commands);

to
$cmds_regexp = join("|", map quotemeta($_), @commands);

-jeremy
Árni Birgisson
2009-10-30 09:35:47 UTC
Permalink
You sir, are awesome :-)

This works like a charm.

For anyone else thinking about doing the same my changes include:
* The changes from jeremy
* adding a new parser called ShowConfigurationDisplaySet (copied from
some other simple parser)
* adding a command to the commandtable "show configuration | display
set | no-more" => 'ShowConfigurationDisplaySet'.

Thank you for your help!

-Arni
Post by Jeremy Singletary
Change
to
-jeremy
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
Arni Birgisson
Network Engineer
FATTOC Iceland
Adalstraeti 6
101 Reykjavik
Iceland
Iñaki Martinez Diez
2009-10-30 10:14:13 UTC
Permalink
Post by Árni Birgisson
You sir, are awesome :-)
This works like a charm.
* The changes from jeremy
* adding a new parser called ShowConfigurationDisplaySet (copied from
some other simple parser)
* adding a command to the commandtable "show configuration | display
set | no-more" => 'ShowConfigurationDisplaySet'.
Can you attach the complete file i am interested, thank you.
Árni Birgisson
2009-10-30 10:30:20 UTC
Permalink
Here you go.

This is a replacement for /usr/libexec/rancid/jrancid

Loading...