<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I need to run "show | compare" in JunOS by entering in configure mode, so I would like to add this command to the list of commands that gets executed against Juniper devices.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
At first I tried to edit directly the files "junos.pm", "jrancid" and "rancid.types.base" but without success.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
After several searches on the internet and here I found some interesting information.
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<a href="https://shrubbery.net/pipermail/rancid-discuss/2015-October/008716.html" id="LPlnk709477">https://shrubbery.net/pipermail/rancid-discuss/2015-October/008716.html</a></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<a href="https://shrubbery.net/pipermail/rancid-discuss/2016-September/009251.html" id="LPlnk186791">https://shrubbery.net/pipermail/rancid-discuss/2016-September/009251.html</a></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<a href="https://shrubbery.net/pipermail/rancid-discuss/2009-October/004326.html" id="LPlnk612119">https://shrubbery.net/pipermail/rancid-discuss/2009-October/004326.html</a></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
So I don't override commands from the base types file and copy them from rancid.types.base to rancid.types.conf and rename them.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Of course without forgetting to update the "router.db" file with the value jlocal and copy /usr/local/libexec/rancid/jrancid to /usr/local/libexec/rancid/jlocal (I use FreeBSD OS).<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Example conf:</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
jlocal;script;rancid -t jlocal
<div>jlocal;login;jlogin</div>
<div>jlocal;module;junos</div>
<div>jlocal;inloop;junos::inloop</div>
<div>jlocal;command;junos::ShowChassisClocks;show chassis clocks</div>
<div>jlocal;command;junos::ShowChassisEnvironment;show chassis environment</div>
<div>jlocal;command;junos::ShowChassisFirmware;show chassis firmware</div>
<div>jlocal;command;junos::ShowChassisFpcDetail;show chassis fpc detail</div>
<div>jlocal;command;junos::ShowChassisHardware;show chassis hardware detail</div>
<div>jlocal;command;junos::ShowChassisHardware;show chassis hardware models</div>
<div>jlocal;command;junos::ShowChassisRoutingEngine;show chassis routing-engine</div>
<div>jlocal;command;junos::ShowChassisSCB;show chassis scb</div>
<div>jlocal;command;junos::ShowChassisSCB;show chassis sfm detail</div>
<div>jlocal;command;junos::ShowChassisSCB;show chassis ssb</div>
<div>jlocal;command;junos::ShowChassisSCB;show chassis feb detail</div>
<div>jlocal;command;junos::ShowChassisSCB;show chassis feb</div>
<div>jlocal;command;junos::ShowChassisSCB;show chassis cfeb</div>
<div>jlocal;command;junos::ShowChassisAlarms;show chassis alarms</div>
<div>jlocal;command;junos::ShowSystemLicense;show system license</div>
<div>jlocal;command;junos::ShowSystemBootMessages;show system boot-messages</div>
<div>jlocal;command;junos::ShowSystemCoreDumps;show system core-dumps</div>
<div>jlocal;command;junos::ShowVersion;show version detail</div>
jlocal;command;junos::ShowConfiguration;show configuration</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
So far everything works fine, but if I add the additional lines for my commands in "rancid.types.conf" it doesn't work anymore.
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
jlocal;command;junos::RunConfigure;configure<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
jlocal;command;junos::ShowCompare;show | compare<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
jlocal;command;junos::RunExit;exit</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I also tried to add the commands in the @commandtable array and also to modify the variable $prompt in order to take the '#' of the configure mode.<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
$prompt = ($_ =~ /^([^>]+>)/)[0]; ===> $prompt = ($_ =~ /^([^>|^#]+[>|#])/)[0];<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Can someone please explain to me how I can set this up? Thank you.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Regards.<br>
</div>
</body>
</html>