[rancid] [PATCH] escape double quotes in command string

Anderson, Charles R cra at wpi.edu
Mon Feb 18 18:20:20 UTC 2019


I'd like to add some custom Junos commands in rancid.types.conf such as:

wpi-juniper;command;junos::ShowChassisHardware;show lldp neighbors | match "^Local | ae[0-9]+ "
wpi-juniper;command;junos::ShowChassisHardware;show system commit | except ^rescue | trim 4 | except "by apipush via"

These are rather WPI-specific, filtering output based on local conventions, so they are not suitable for distribution with upstream
RANCID (although the "show system commit | except ^rescue | trim 4" part could be worthy of upstream inclusion--it shows the commit messages people gave when they changed the config--but the rollback numbers rotate and need to be trimmed out, hence the "| trim 4" part).  By doing filtering in the Junos CLI, it allows local customizations without the need to write a new RANCID module to filter the output.  This works fine except for the " double quote characters, which mess up when passed to system() and open() calls.  The attached patch escapes these double quotes before passing the command to the system() or open().  The \" escaping cannot be done in rancid.types.conf because it will cause problems with the command name not matching the CLI output.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: rancid-3.9-escape-doublequotes-in-commandstr.patch
URL: <http://www.shrubbery.net/pipermail/rancid-discuss/attachments/20190218/09d8b337/attachment.ksh>


More information about the Rancid-discuss mailing list