<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta content="text/html; charset=iso-8859-1">
<style type="text/css" style="">
<!--
p
{margin-top:0;
margin-bottom:0}
-->
</style>
</head>
<body dir="ltr">
<style id="outgoing-font-settings">
<!--
#response_container_BBPPID
{font-family:initial;
font-size:initial;
color:initial}
-->
</style>
<meta content="script-src 'self'; img-src http: https: cid: data:;">
<div id="response_container_BBPPID" dir="auto" style="outline:none">
<div name="BB10" id="BB10_response_div_BBPPID" dir="auto" style="width:100%">Does it have to be done from configure mode?</div>
<div name="BB10" id="BB10_response_div_BBPPID" dir="auto" style="width:100%">Would</div>
<div name="BB10" id="BB10_response_div_BBPPID" dir="auto" style="width:100%">'show configuration | compare rollback 0'</div>
<div name="BB10" id="BB10_response_div_BBPPID" dir="auto" style="width:100%">From normal mode suffice?</div>
<div name="BB10" id="BB10_response_div_BBPPID" dir="auto" style="width:100%"><br>
</div>
<div name="BB10" id="BB10_response_div_BBPPID" dir="auto" style="width:100%">Thinking for the sake of simplicity. But looks like you are on the right track to me</div>
<div name="BB10" id="response_div_spacer_BBPPID" dir="auto" style="width:100%"><br style="display:initial">
</div>
<div id="blackberry_signature_BBPPID" name="BB10" dir="auto">
<div id="_signaturePlaceholder_BBPPID" name="BB10" dir="auto">Sent from my BlackBerry — the most secure mobile device — via the TELUS Network</div>
</div>
</div>
<div id="_original_msg_header_BBPPID" dir="auto">
<table width="100%" style="border-spacing:0px; display:table; outline:none">
<tbody>
<tr>
<td colspan="2" style="padding:initial; font-size:initial; text-align:initial">
<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 id="from"><b>From:</b> peacefull64@hotmail.fr</div>
<div id="sent"><b>Sent:</b> January 24, 2021 8:10 AM</div>
<div id="to"><b>To:</b> rancid-discuss@www.shrubbery.net</div>
<div id="subject"><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" 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>
</div>
</body>
</html>