<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div dir="auto"><div style="box-sizing: inherit; color: rgb(77, 82, 89); font-family: Lato, Arial, Helvetica, sans-serif; font-size: 16px; white-space: normal; background-color: rgb(255, 255, 255);"><p style="box-sizing: inherit; margin: 0px 0px 16px;">Yes, it's must be done from configure mode because is not the same information. </p><p style="box-sizing: inherit; margin: 0px 0px 16px;">For example, in operational mode, you can compare the active configuration to a previously committed configuration by using the following commands:</p></div><ul style="box-sizing: inherit; list-style-position: initial; list-style-image: initial; margin: 0px 0px 1rem 1.714rem; padding: 0px; color: rgb(77, 82, 89); font-family: Lato, Arial, Helvetica, sans-serif; font-size: 16px; white-space: normal; background-color: rgb(255, 255, 255);"><li style="box-sizing: inherit; padding: 5px 0px;"><p style="box-sizing: inherit; margin: 0px;"><span class="cli" style="box-sizing: inherit; font-family: "Courier New", Courier, monospace, sans-serif; padding: 0px; margin: 0px;">show configuration | compare revision <var v-pre="" style="box-sizing: inherit;">revision-id</var></span></p></li><li style="box-sizing: inherit; padding: 5px 0px;"><p style="box-sizing: inherit; margin: 0px;"><span class="cli" style="box-sizing: inherit; font-family: "Courier New", Courier, monospace, sans-serif; padding: 0px; margin: 0px;">show configuration | compare rollback <var v-pre="" style="box-sizing: inherit;">rollback-number</var></span></p></li></ul><div style="box-sizing: inherit; color: rgb(77, 82, 89); font-family: Lato, Arial, Helvetica, sans-serif; font-size: 16px; white-space: normal; background-color: rgb(255, 255, 255);"><p style="box-sizing: inherit; margin: 0px 0px 16px;">Similarly in configuration mode, you can compare the candidate configuration to a previously committed configuration by using the following commands:</p></div><ul style="box-sizing: inherit; list-style-position: initial; list-style-image: initial; margin: 0px 0px 1rem 1.714rem; padding: 0px; color: rgb(77, 82, 89); font-family: Lato, Arial, Helvetica, sans-serif; font-size: 16px; white-space: normal; background-color: rgb(255, 255, 255);"><li style="box-sizing: inherit; padding: 5px 0px;"><p style="box-sizing: inherit; margin: 0px;"><span class="cli" style="box-sizing: inherit; font-family: "Courier New", Courier, monospace, sans-serif; padding: 0px; margin: 0px;">show | compare revision <var v-pre="" style="box-sizing: inherit;">revision-id</var></span></p></li><li style="box-sizing: inherit; padding: 5px 0px;"><p style="box-sizing: inherit; margin: 0px;"><span class="cli" style="box-sizing: inherit; font-family: "Courier New", Courier, monospace, sans-serif; padding: 0px; margin: 0px;">show | compare rollback <var v-pre="" style="box-sizing: inherit;">rollback-number</var></span></p></li></ul><br>https://www.juniper.net/documentation/en_US/junos/topics/task/operational/junos-xml-protocol-requesting-configuration-comparison.html<div><br></div><div>Regards. </div></div><div style="line-height:1.5"><br><br>-------- Message original --------<br>De : Emille Blanc <emille@abccommunications.com><br>Date : dim. 24 janv. 2021 à 17:14<br>À : "Dede ." <peacefull64@hotmail.fr>, rancid-discuss@www.shrubbery.net<br>Objet : Re: [rancid] Adding JunOS Commands in configure mode<br><blockquote><div dir="ltr">


<div dir="auto" style="outline:none">
<div dir="auto" style="width:100%">Does it have to be done from configure mode?</div>
<div dir="auto" style="width:100%">Would</div>
<div dir="auto" style="width:100%">'show configuration  | compare rollback 0'</div>
<div dir="auto" style="width:100%">From normal mode suffice?</div>
<div dir="auto" style="width:100%"><br>
</div>
<div dir="auto" style="width:100%">Thinking for the sake of simplicity.  But looks like you are on the right track to me</div>
<div dir="auto" style="width:100%"><br>
</div>
<div dir="auto">
<div dir="auto">Sent from my BlackBerry — the most secure mobile device — via the TELUS Network</div>
</div>
</div>
<div dir="auto">
<table width="100%" style="border-spacing:0px;display:table;outline:none"><tbody><tr><td colspan="2">
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb( 181 , 196 , 223 );padding:3pt 0in 0in;font-family:'tahoma' , 'bb alpha sans' , 'slate pro';font-size:10pt">
<div><b>From:</b> peacefull64@hotmail.fr</div>
<div><b>Sent:</b> January 24, 2021 8:10 AM</div>
<div><b>To:</b> rancid-discuss@www.shrubbery.net</div>
<div><b>Subject:</b> [rancid] Adding JunOS Commands in configure mode</div>
</div>
</td></tr></tbody></table>
<br>
</div>
<div>
<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">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">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">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>
</div>
</div>
</blockquote></div>