<div dir="ltr"><div dir="ltr"><p class="MsoNormal"><span style="font-family:Arial,sans-serif">Hi<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">I have been working on getting RANCID to collect configuration information from some equipment that is made by InfiNet. So far I have been unable to locate any similar work performed previously and so made a start on getting RANCID to connect to the devices.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">Through trial and error I found that the “jlogin” login script was able to connect to the device but would not allow interaction once connected. I decided to use that script as a base for my work and so made a copy of it and named that copy “infilogin” I found that the reason that issues were being hit was that the match of the prompt string was being thrown off as the InfiNet device changes it’s prompt, and that there were trailing charaters what were causing issues.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">With regards the changing prompt I saw it take the two following forms:<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">basehostname><u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">basehostname$1><u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">And the trailing characters I saw were:<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">\r\u001b[16C\u001b[K\r\u001b[16C<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">To work around this I created an “”altprompt” which took a substring of “$prompt” and then did some greedy matching which then gave the following in the “we are now logged in, figure out the full prompt”<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">[..<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">    # we are logged in, now figure out the full prompt<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">    send "\r"<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">    expect {<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">        -re "(\r\n|\n)"         { exp_continue; }<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">        -re "^\[^ ]+$prompt"    { set prompt $expect_out(0,string);<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">                                  <b>regsub ">" $prompt ">" prompt;       </b>                                                   <<<<<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">                                }<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">    }<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">    # send $prompt<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">    set in_proc 0<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">    return 0<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">}<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif"># Run commands given on the command line.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">proc run_commands { prompt command } {<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">    global do_interact in_proc<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">    set in_proc 1<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">  <b>  set altprompt [string range $prompt 0 11]   </b>                                                                      <<<<<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">    # handle escaped ;s in commands, and ;; and ^;<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">    regsub -all {([^\\]);} $command <a>\\1\u0002;</a> esccommand<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">    regsub -all {([^\\]);;} $esccommand <a>\\1;\u0002;</a> command<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">    regsub {^;} $command "\u0002;" esccommand<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">    regsub -all {[\\];} $esccommand ";" command<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">    regsub -all {\u0002;} $command "\u0002" esccommand<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">    set sep "\u0002"<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">    set commands [split $esccommand $sep]<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">    set num_commands [llength $commands]<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">    for {set i 0} {$i < $num_commands} { incr i} {<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">        send -- "[subst -nocommands [lindex $commands $i]]\r"<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">        expect {<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">            <b>-re "^\[^\n\r *]*$prompt.*" {}</b>                                                                                        <<<<<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">         <b>   -re "^$altprompt.*>.*"      {} </b>                                                                                        <<<<<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">            -re "^\[^\n\r]*$prompt."    { exp_continue }<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">            -re "(\r\n|\n)"             { exp_continue }<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">           <b> -re "\r-- more --\r"        { send " "; exp_continue }   </b>                                                   <<<<<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">        }<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">    }<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">..]<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">I have marked my deviations from “jlogin” with four less than signs.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">With these bodges applied I can successfully get connected to a device, execute commands and exit. I can also issue the “infilogin” with -c or -x and  the relevant commands will execute, and I see the output. I then went and updated the “rancid.types.conf” with an entry as below:<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">[..<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">infinet;script;rancid -t infinet<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">infinet;login;jlogin<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">infinet;module;infinet<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">infinet;inloop;infinet::inloop<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">infinet;command;infinet::ShowVersion;system version<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">infinet;command;infinet::ShowConfiguration;config show<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">..]<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">I created an “<a href="http://infinet.pm/" target="_blank">infinet.pm</a>” based on “<a href="http://mrv.pm/" target="_blank">mrv.pm</a>”, made an addition to the “router.db” and now I can see when “rancid-run” is called that the system connects out 4 times to the InfiNet device (tcpdump helped here) but in the log file for the run I keep seeing :<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif"><a href="http://10.126.254.208/" target="_blank">10.12.25.208</a>: missed cmd(s): all commands<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif"><a href="http://10.126.254.208/" target="_blank">10.12.25.208</a>: End of run not found<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">From what I have read it would seem that my issue lies with the “inloop” within my “<a href="http://infinet.pm/" target="_blank">infinet.pm</a>” file, but cannot get to grips with what needs to be there, or if the “$prompt” hacks I made in “infilogin” are coming back to bite me now. If anyone can point me in the right direction I will be very grateful.<u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:Arial,sans-serif">Thank you for taking the time to read this and for supporting this great tool. (By that I mean RANCID not that I am a tool . . but now I come to mention it)</span></p><div><br></div><div dir="ltr" class="gmail_signature">DeeTee<br><br><br></div></div></div>