<div dir="ltr"><div dir="ltr"><div dir="ltr">Hi<div><br></div><div>I need to send you a huge thanks for your help. Your input was critical to me getting this</div><div>bit of work done. In the early hours of this morning RANCID collected the config of 48 out</div><div>of 50 of the InfiNet devices. Will tinker with the last two in the coming days / weeks.</div><div><br></div><div>In order to get the "./rancid -d -t <type>" to work correctly for me I had to edit the </div><div>following two lines in "rancid.types.conf":</div><div>     infinet;script;rancid -t infinet</div><div>     infinet;login;infilogin</div><div>So that they read as:</div><div>     infinet;script;./rancid -t infinet</div><div>     infinet;login;/usr/local/rancid/bin/infilogin</div><div><br></div><div>This then meant that my <device>.new and <device>.raw files would populate and I</div><div>was able to troubleshoot the issues that were happening in inLoop. The big problem</div><div>that I was facing was that the "$" in the hostname was being read as a variable in PERL.</div><div><br></div><div>As the RANCID SSH was always the 1st connection the hostname had "$1" at the</div><div>end and so PERL was looking at the contents of $1 - which threw off all the prompt </div><div>matches. In trying to remove that (with my poor PERL skills) I stumbled over </div><div>a not so elegant solution of using:</div><div>     tr/\$/\\/;</div><div>In each of the subroutines in the <a href="http://infinet.pm">infinet.pm</a> file (just after each occurence of "tr/\015//d;")</div><div>This way the hostname was viewed consistently throughout the script.</div><div><br></div><div>After that as we were just looking to grab a plain copy of the config (which is short</div><div>and nice and static) I ended up mostly gutting the sub routines of all the clever matches</div><div>and we got where we needed to be. (might try to tinker and learn about these in </div><div>my own time)</div><div><br></div><div>Once again I am very grateful to you for your guidance and support with this.</div><div><br></div><div>All the very best</div><div><br></div><div>DeeTee</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, 8 Jan 2022 at 18:36, heasley <<a href="mailto:heas@shrubbery.net">heas@shrubbery.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Fri, Jan 07, 2022 at 10:13:58AM +0000, Daniel Thomas:<br>
> Thank you very much for your swift response. I will have a look at clogin<br>
> hlogin (specifically the hpuifilter) to see what I can learn from them.<br>
<br>
There are 4 places in hlogin that deal with hpuifilter.  should be easy<br>
to adopt it or even start with that instead.  the procurve devices are<br>
similar to cisco.<br>
<br>
> I will also clean up the "$prompt" so that it accepts both versions of the<br>
> prompt.<br>
> <br>
> It doesn't appear to be a cmd-line counter - I know that one aspect of the<br>
> behaviour is that the <Dollar Sign><Number> part of the hostname relates to<br>
> how many simultaneous SSH sessions there are. However I cannot understand<br>
> how on some occasions it "reports back" as not including the <Dollar<br>
> Sign><Number> suffix. I will play with the debug again and see what I get.<br>
<br>
I never understand why these prompt things are useful, but ... you want to<br>
match that whether its there or not.  something like this, using the<br>
hostname generically, $prompt =<br>
<br>
        '^hostname(\$[0-9]+)?>'<br>
<br>
or in expectese<br>
        '^hostname(\\\$\[0-9]+)?>'<br>
<br>
forgive me if I dont have the \'s correct.<br>
<br>
> I'm reticent to mention this bit as I think it relates to our installation<br>
> of RANCID and the behaviour of the *nix system on which it lives . . but<br>
> when I have been executing the "rancid -d -t <type>" I get (what I think<br>
> is) non standard behaviour.<br>
> <br>
> If I execute "./rancid -d -t <type>" I get the following behaviour:<br>
> <br>
> ./rancid -d -t infinet 10.126.254.208<br>
> <br>
> <br>
> <br>
> loadtype: device type infinet<br>
> <br>
> loadtype: found device type infinet at<br>
> /usr/local/rancid/etc/rancid.types.conf:119<br>
> <br>
> device script (rancid) does not appear to be me (./rancid): exec(rancid -t<br>
> infinet -d 10.126.254.208)<br>
> <br>
> Can't exec "rancid": No such file or directory at ./rancid line 104.<br>
> <br>
> exec(rancid) failed: No such file or directory<br>
> <br>
> <br>
> <br>
> And so no .raw nor .new is generated.<br>
> <br>
> <br>
> <br>
> If I execute<br>
> <br>
> <br>
> <br>
> perl rancid -d -t infinet 10.126.254.208<br>
> <br>
> loadtype: device type infinet<br>
> <br>
> loadtype: found device type infinet at<br>
> /usr/local/rancid/etc/rancid.types.conf:119<br>
> <br>
> executing infilogin -t 90 -c"system version;config show" 10.126.254.208<br>
> <br>
> <a href="http://10.126.254.208" rel="noreferrer" target="_blank">10.126.254.208</a>: missed cmd(s): all commands<br>
> <br>
> <a href="http://10.126.254.208" rel="noreferrer" target="_blank">10.126.254.208</a>: End of run not found<br>
> <br>
> <a href="http://10.126.254.208" rel="noreferrer" target="_blank">10.126.254.208</a>: clean_run is false<br>
> <br>
> <a href="http://10.126.254.208" rel="noreferrer" target="_blank">10.126.254.208</a>: found_end is false<br>
> <br>
> !<br>
> <br>
> <br>
> <br>
> Then raw and new are generated but the .raw then contains:<br>
> <br>
> <br>
> <br>
> sh: infilogin: command not found<br>
> <br>
> <br>
> <br>
> Which I understand to be the shell expressing it does not recognise that<br>
> command. However as mentioned previously everything seems to run fine when<br>
> “rancid-run” is called.<br>
> <br>
> <br>
> I mention this as it hampers me a bit on the more granular troubleshooting<br>
> that is available.<br>
<br>
yes; it actually improves troubleshooting :)  for me anyway.  if you adopt<br>
the path set in rancid.conf, that should solve this for you.  But, it can<br>
also be manipulated to test local versions, as can evn(PERLV_PATH) be set<br>
to for local versions of rancid modules.<br>
<br>
> <br>
> Thanks again<br>
> <br>
> <br>
> DeeTee<br>
> <br>
> <br>
> On Thu, 6 Jan 2022 at 22:55, heasley <<a href="mailto:heas@shrubbery.net" target="_blank">heas@shrubbery.net</a>> wrote:<br>
> <br>
> > Thu, Jan 06, 2022 at 10:23:44PM +0000, Daniel Thomas:<br>
> > > Hi<br>
> > ><br>
> > ><br>
> > ><br>
> > > I have been working on getting RANCID to collect configuration<br>
> > information<br>
> > > from some equipment that is made by InfiNet. So far I have been unable to<br>
> > > locate any similar work performed previously and so made a start on<br>
> > getting<br>
> > > RANCID to connect to the devices.<br>
> > ><br>
> > ><br>
> > ><br>
> > > Through trial and error I found that the “jlogin” login script was able<br>
> > to<br>
> > > connect to the device but would not allow interaction once connected. I<br>
> > > decided to use that script as a base for my work and so made a copy of it<br>
> > > and named that copy “infilogin” I found that the reason that issues were<br>
> > > being hit was that the match of the prompt string was being thrown off as<br>
> > > the InfiNet device changes it’s prompt, and that there were trailing<br>
> > > charaters what were causing issues.<br>
> > ><br>
> > > With regards the changing prompt I saw it take the two following forms:<br>
> > > basehostname><br>
> > > basehostname$1><br>
> > ><br>
> > > And the trailing characters I saw were:<br>
> > ><br>
> > > \r\u001b[16C\u001b[K\r\u001b[16C<br>
> > ><br>
> > > To work around this I created an “”altprompt” which took a substring of<br>
> > > “$prompt” and then did some greedy matching which then gave the following<br>
> > > in the “we are now logged in, figure out the full prompt”<br>
> ><br>
> > You might look at clogin; the EXOS also has a command line counter.  Is it<br>
> > a cmd-line counter?<br>
> ><br>
> > And, look at hlogin, which uses hpuifilter to remove most of the screen<br>
> > manipulation escape codes.  Sometimes a more rudimentary TERM type causes<br>
> > devices no use the escape codes; like 'network' or 'dumb'.  there are at<br>
> > least 2 *.pm's that do this.<br>
> ><br>
> > I think that if you combine these two methods, it will be easier.  copy<br>
> > clogin and modify for the prompt alternatives, add the hpuifilter changes<br>
> > from hlogin.<br>
> ><br>
> > if thats not attractive, debug the missed commands with rancid -d -t <type><br>
> > looking for the command matches.  I expect there will be none and the *.new<br>
> > file will be empty.  Compare the prompt matchine in inloop() to whats in<br>
> > the *.raw file and look for escape codes in the prompts within the *.raw<br>
> > file.<br>
> ><br>
> > below, I would just alter $prompt to accept either version of the prompt.<br>
> > That will make it easier (more consistent with other scripts) for -x or<br>
> > -s.<br>
> ><br>
> > > [..<br>
> > ><br>
> > ><br>
> > ><br>
> > >     # we are logged in, now figure out the full prompt<br>
> > ><br>
> > >     send "\r"<br>
> > ><br>
> > >     expect {<br>
> > ><br>
> > >         -re "(\r\n|\n)"         { exp_continue; }<br>
> > ><br>
> > >         -re "^\[^ ]+$prompt"    { set prompt $expect_out(0,string);<br>
> > ><br>
> > >                                   *regsub ">" $prompt ">" prompt;<br>
> > >  *<br>
> > >                                  <<<<<br>
> > ><br>
> > >                                 }<br>
> > ><br>
> > >     }<br>
> > ><br>
> > >     # send $prompt<br>
> > ><br>
> > >     set in_proc 0<br>
> > ><br>
> > >     return 0<br>
> > ><br>
> > > }<br>
> > ><br>
> > ><br>
> > ><br>
> > > # Run commands given on the command line.<br>
> > ><br>
> > > proc run_commands { prompt command } {<br>
> > ><br>
> > >     global do_interact in_proc<br>
> > ><br>
> > >     set in_proc 1<br>
> > ><br>
> > ><br>
> > ><br>
> > >   *  set altprompt [string range $prompt 0 11]   *<br>
> > >               <<<<<br>
> > ><br>
> > >     # handle escaped ;s in commands, and ;; and ^;<br>
> > ><br>
> > >     regsub -all {([^\\]);} $command \\1\u0002; esccommand<br>
> > ><br>
> > >     regsub -all {([^\\]);;} $esccommand \\1;\u0002; command<br>
> > ><br>
> > >     regsub {^;} $command "\u0002;" esccommand<br>
> > ><br>
> > >     regsub -all {[\\];} $esccommand ";" command<br>
> > ><br>
> > >     regsub -all {\u0002;} $command "\u0002" esccommand<br>
> > ><br>
> > >     set sep "\u0002"<br>
> > ><br>
> > >     set commands [split $esccommand $sep]<br>
> > ><br>
> > >     set num_commands [llength $commands]<br>
> > ><br>
> > >     for {set i 0} {$i < $num_commands} { incr i} {<br>
> > ><br>
> > >         send -- "[subst -nocommands [lindex $commands $i]]\r"<br>
> > ><br>
> > >         expect {<br>
> > ><br>
> > >             *-re "^\[^\n\r *]*$prompt.*" {}*<br>
> > >                             <<<<<br>
> > ><br>
> > >          *   -re "^$altprompt.*>.*"      {} *<br>
> > > <<<<<br>
> > ><br>
> > >             -re "^\[^\n\r]*$prompt."    { exp_continue }<br>
> > ><br>
> > >             -re "(\r\n|\n)"             { exp_continue }<br>
> > ><br>
> > >            * -re "\r-- more --\r"        { send " "; exp_continue }<br>
> > > *<br>
> > >                        <<<<<br>
> > ><br>
> > >         }<br>
> > ><br>
> > >     }<br>
> > ><br>
> > ><br>
> > ><br>
> > ><br>
> > ><br>
> > > ..]<br>
> > ><br>
> > ><br>
> > ><br>
> > > I have marked my deviations from “jlogin” with four less than signs.<br>
> > ><br>
> > ><br>
> > ><br>
> > > With these bodges applied I can successfully get connected to a device,<br>
> > > execute commands and exit. I can also issue the “infilogin” with -c or -x<br>
> > > and  the relevant commands will execute, and I see the output. I then<br>
> > went<br>
> > > and updated the “rancid.types.conf” with an entry as below:<br>
> > ><br>
> > ><br>
> > ><br>
> > > [..<br>
> > ><br>
> > > infinet;script;rancid -t infinet<br>
> > ><br>
> > > infinet;login;jlogin<br>
> > ><br>
> > > infinet;module;infinet<br>
> > ><br>
> > > infinet;inloop;infinet::inloop<br>
> > ><br>
> > > infinet;command;infinet::ShowVersion;system version<br>
> > ><br>
> > > infinet;command;infinet::ShowConfiguration;config show<br>
> > ><br>
> > > ..]<br>
> > ><br>
> > ><br>
> > ><br>
> > > I created an “<a href="http://infinet.pm" rel="noreferrer" target="_blank">infinet.pm</a>” based on “<a href="http://mrv.pm" rel="noreferrer" target="_blank">mrv.pm</a>”, made an addition to the<br>
> > > “router.db” and now I can see when “rancid-run” is called that the system<br>
> > > connects out 4 times to the InfiNet device (tcpdump helped here) but in<br>
> > the<br>
> > > log file for the run I keep seeing :<br>
> > ><br>
> > ><br>
> > ><br>
> > > 10.12.25.208 <<a href="http://10.126.254.208/" rel="noreferrer" target="_blank">http://10.126.254.208/</a>>: missed cmd(s): all commands<br>
> > ><br>
> > > 10.12.25.208 <<a href="http://10.126.254.208/" rel="noreferrer" target="_blank">http://10.126.254.208/</a>>: End of run not found<br>
> > ><br>
> > ><br>
> > ><br>
> > > >From what I have read it would seem that my issue lies with the “inloop”<br>
> > > within my “<a href="http://infinet.pm" rel="noreferrer" target="_blank">infinet.pm</a>” file, but cannot get to grips with what needs to<br>
> > be<br>
> > > there, or if the “$prompt” hacks I made in “infilogin” are coming back to<br>
> > > bite me now. If anyone can point me in the right direction I will be very<br>
> > > grateful.<br>
> > ><br>
> > ><br>
> > ><br>
> > > Thank you for taking the time to read this and for supporting this great<br>
> > > tool. (By that I mean RANCID not that I am a tool . . but now I come to<br>
> > > mention it)<br>
> > ><br>
> > > DeeTee<br>
> ><br>
> > > _______________________________________________<br>
> > > Rancid-discuss mailing list<br>
> > > <a href="mailto:Rancid-discuss@www.shrubbery.net" target="_blank">Rancid-discuss@www.shrubbery.net</a><br>
> > > <a href="https://www.shrubbery.net/mailman/listinfo/rancid-discuss" rel="noreferrer" target="_blank">https://www.shrubbery.net/mailman/listinfo/rancid-discuss</a><br>
> ><br>
> ><br>
> <br>
> -- <br>
> Regards<br>
> <br>
> Daniel Thomas<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Regards<br><br>Daniel Thomas<br><br><br></div></div></div>