Mailing List Archive

Trying to backup InfiNet Devices
Hi



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.



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.



With regards the changing prompt I saw it take the two following forms:



basehostname>



basehostname$1>



And the trailing characters I saw were:



\r\u001b[.16C\u001b[.K\r\u001b[.16C





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”



[..



# we are logged in, now figure out the full prompt

send "\r"

expect {

-re "(\r\n|\n)" { exp_continue; }

-re "^\[^ ]+$prompt" { set prompt $expect_out(0,string);

*regsub ">" $prompt ">" prompt;
*
<<<<

}

}

# send $prompt

set in_proc 0

return 0

}



# Run commands given on the command line.

proc run_commands { prompt command } {

global do_interact in_proc

set in_proc 1



* set altprompt [string range $prompt 0 11] *
<<<<

# handle escaped ;s in commands, and ;; and ^;

regsub -all {([^\\]);} $command \\1\u0002; esccommand

regsub -all {([^\\]);;} $esccommand \\1;\u0002; command

regsub {^;} $command "\u0002;" esccommand

regsub -all {[\\];} $esccommand ";" command

regsub -all {\u0002;} $command "\u0002" esccommand

set sep "\u0002"

set commands [split $esccommand $sep]

set num_commands [llength $commands]

for {set i 0} {$i < $num_commands} { incr i} {

send -- "[subst -nocommands [lindex $commands $i]]\r"

expect {

*-re "^\[^\n\r *]*$prompt.*" {}*
<<<<

* -re "^$altprompt.*>.*" {} *
<<<<

-re "^\[^\n\r]*$prompt." { exp_continue }

-re "(\r\n|\n)" { exp_continue }

* -re "\r-- more --\r" { send " "; exp_continue }
*
<<<<

}

}





..]



I have marked my deviations from “jlogin” with four less than signs.



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:



[...

infinet;script;rancid -t infinet

infinet;login;jlogin

infinet;module;infinet

infinet;inloop;infinet::inloop

infinet;command;infinet::ShowVersion;system version

infinet;command;infinet::ShowConfiguration;config show

..]



I created an “infinet.pm” based on “mrv.pm”, 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 :



10.12.25.208 <http://10.126.254.208/>: missed cmd(s): all commands

10.12.25.208 <http://10.126.254.208/>: End of run not found



From what I have read it would seem that my issue lies with the “inloop”
within my “infinet.pm” 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.



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)

DeeTee
Re: Trying to backup InfiNet Devices [ In reply to ]
Thu, Jan 06, 2022 at 10:23:44PM +0000, Daniel Thomas:
> Hi
>
>
>
> 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.
>
>
>
> 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.
>
> With regards the changing prompt I saw it take the two following forms:
> basehostname>
> basehostname$1>
>
> And the trailing characters I saw were:
>
> \r\u001b[.16C\u001b[.K\r\u001b[.16C
>
> 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”

You might look at clogin; the EXOS also has a command line counter. Is it
a cmd-line counter?

And, look at hlogin, which uses hpuifilter to remove most of the screen
manipulation escape codes. Sometimes a more rudimentary TERM type causes
devices no use the escape codes; like 'network' or 'dumb'. there are at
least 2 *.pm's that do this.

I think that if you combine these two methods, it will be easier. copy
clogin and modify for the prompt alternatives, add the hpuifilter changes
from hlogin.

if thats not attractive, debug the missed commands with rancid -d -t <type>
looking for the command matches. I expect there will be none and the *.new
file will be empty. Compare the prompt matchine in inloop() to whats in
the *.raw file and look for escape codes in the prompts within the *.raw file.

below, I would just alter $prompt to accept either version of the prompt.
That will make it easier (more consistent with other scripts) for -x or
-s.

> [..
>
>
>
> # we are logged in, now figure out the full prompt
>
> send "\r"
>
> expect {
>
> -re "(\r\n|\n)" { exp_continue; }
>
> -re "^\[^ ]+$prompt" { set prompt $expect_out(0,string);
>
> *regsub ">" $prompt ">" prompt;
> *
> <<<<
>
> }
>
> }
>
> # send $prompt
>
> set in_proc 0
>
> return 0
>
> }
>
>
>
> # Run commands given on the command line.
>
> proc run_commands { prompt command } {
>
> global do_interact in_proc
>
> set in_proc 1
>
>
>
> * set altprompt [string range $prompt 0 11] *
> <<<<
>
> # handle escaped ;s in commands, and ;; and ^;
>
> regsub -all {([^\\]);} $command \\1\u0002; esccommand
>
> regsub -all {([^\\]);;} $esccommand \\1;\u0002; command
>
> regsub {^;} $command "\u0002;" esccommand
>
> regsub -all {[\\];} $esccommand ";" command
>
> regsub -all {\u0002;} $command "\u0002" esccommand
>
> set sep "\u0002"
>
> set commands [split $esccommand $sep]
>
> set num_commands [llength $commands]
>
> for {set i 0} {$i < $num_commands} { incr i} {
>
> send -- "[subst -nocommands [lindex $commands $i]]\r"
>
> expect {
>
> *-re "^\[^\n\r *]*$prompt.*" {}*
> <<<<
>
> * -re "^$altprompt.*>.*" {} *
> <<<<
>
> -re "^\[^\n\r]*$prompt." { exp_continue }
>
> -re "(\r\n|\n)" { exp_continue }
>
> * -re "\r-- more --\r" { send " "; exp_continue }
> *
> <<<<
>
> }
>
> }
>
>
>
>
>
> ..]
>
>
>
> I have marked my deviations from “jlogin” with four less than signs.
>
>
>
> 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:
>
>
>
> [...
>
> infinet;script;rancid -t infinet
>
> infinet;login;jlogin
>
> infinet;module;infinet
>
> infinet;inloop;infinet::inloop
>
> infinet;command;infinet::ShowVersion;system version
>
> infinet;command;infinet::ShowConfiguration;config show
>
> ..]
>
>
>
> I created an “infinet.pm” based on “mrv.pm”, 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 :
>
>
>
> 10.12.25.208 <http://10.126.254.208/>: missed cmd(s): all commands
>
> 10.12.25.208 <http://10.126.254.208/>: End of run not found
>
>
>
> >From what I have read it would seem that my issue lies with the “inloop”
> within my “infinet.pm” 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.
>
>
>
> 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)
>
> DeeTee

> _______________________________________________
> Rancid-discuss mailing list
> Rancid-discuss@www.shrubbery.net
> https://www.shrubbery.net/mailman/listinfo/rancid-discuss

_______________________________________________
Rancid-discuss mailing list
Rancid-discuss@www.shrubbery.net
https://www.shrubbery.net/mailman/listinfo/rancid-discuss
Re: Trying to backup InfiNet Devices [ In reply to ]
Thank you very much for your swift response. I will have a look at clogin
hlogin (specifically the hpuifilter) to see what I can learn from them.

I will also clean up the "$prompt" so that it accepts both versions of the
prompt.

It doesn't appear to be a cmd-line counter - I know that one aspect of the
behaviour is that the <Dollar Sign><Number> part of the hostname relates to
how many simultaneous SSH sessions there are. However I cannot understand
how on some occasions it "reports back" as not including the <Dollar

I'm reticent to mention this bit as I think it relates to our installation
of RANCID and the behaviour of the *nix system on which it lives . . but
when I have been executing the "rancid -d -t <type>" I get (what I think
is) non standard behaviour.

If I execute "./rancid -d -t <type>" I get the following behaviour:

./rancid -d -t infinet 10.126.254.208



loadtype: device type infinet

loadtype: found device type infinet at
/usr/local/rancid/etc/rancid.types.conf:119

device script (rancid) does not appear to be me (./rancid): exec(rancid -t
infinet -d 10.126.254.208)

Can't exec "rancid": No such file or directory at ./rancid line 104.

exec(rancid) failed: No such file or directory



And so no .raw nor .new is generated.



If I execute



perl rancid -d -t infinet 10.126.254.208

loadtype: device type infinet

loadtype: found device type infinet at
/usr/local/rancid/etc/rancid.types.conf:119

executing infilogin -t 90 -c"system version;config show" 10.126.254.208

10.126.254.208: missed cmd(s): all commands

10.126.254.208: End of run not found

10.126.254.208: clean_run is false

10.126.254.208: found_end is false

!



Then raw and new are generated but the .raw then contains:



sh: infilogin: command not found



Which I understand to be the shell expressing it does not recognise that
command. However as mentioned previously everything seems to run fine when
“rancid-run” is called.


I mention this as it hampers me a bit on the more granular troubleshooting
that is available.


Thanks again


DeeTee

On Thu, 6 Jan 2022 at 22:55, heasley <heas@shrubbery.net> wrote:

> Thu, Jan 06, 2022 at 10:23:44PM +0000, Daniel Thomas:
> > Hi
> >
> >
> >
> > 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.
> >
> >
> >
> > 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.
> >
> > With regards the changing prompt I saw it take the two following forms:
> > basehostname>
> > basehostname$1>
> >
> > And the trailing characters I saw were:
> >
> > \r\u001b[.16C\u001b[.K\r\u001b[.16C
> >
> > 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”
>
> You might look at clogin; the EXOS also has a command line counter. Is it
> a cmd-line counter?
>
> And, look at hlogin, which uses hpuifilter to remove most of the screen
> manipulation escape codes. Sometimes a more rudimentary TERM type causes
> devices no use the escape codes; like 'network' or 'dumb'. there are at
> least 2 *.pm's that do this.
>
> I think that if you combine these two methods, it will be easier. copy
> clogin and modify for the prompt alternatives, add the hpuifilter changes
> from hlogin.
>
> if thats not attractive, debug the missed commands with rancid -d -t <type>
> looking for the command matches. I expect there will be none and the *.new
> file will be empty. Compare the prompt matchine in inloop() to whats in
> the *.raw file and look for escape codes in the prompts within the *.raw
> file.
>
> below, I would just alter $prompt to accept either version of the prompt.
> That will make it easier (more consistent with other scripts) for -x or
> -s.
>
> > [..
> >
> >
> >
> > # we are logged in, now figure out the full prompt
> >
> > send "\r"
> >
> > expect {
> >
> > -re "(\r\n|\n)" { exp_continue; }
> >
> > -re "^\[^ ]+$prompt" { set prompt $expect_out(0,string);
> >
> > *regsub ">" $prompt ">" prompt;
> > *
> > <<<<
> >
> > }
> >
> > }
> >
> > # send $prompt
> >
> > set in_proc 0
> >
> > return 0
> >
> > }
> >
> >
> >
> > # Run commands given on the command line.
> >
> > proc run_commands { prompt command } {
> >
> > global do_interact in_proc
> >
> > set in_proc 1
> >
> >
> >
> > * set altprompt [string range $prompt 0 11] *
> > <<<<
> >
> > # handle escaped ;s in commands, and ;; and ^;
> >
> > regsub -all {([^\\]);} $command \\1\u0002; esccommand
> >
> > regsub -all {([^\\]);;} $esccommand \\1;\u0002; command
> >
> > regsub {^;} $command "\u0002;" esccommand
> >
> > regsub -all {[\\];} $esccommand ";" command
> >
> > regsub -all {\u0002;} $command "\u0002" esccommand
> >
> > set sep "\u0002"
> >
> > set commands [split $esccommand $sep]
> >
> > set num_commands [llength $commands]
> >
> > for {set i 0} {$i < $num_commands} { incr i} {
> >
> > send -- "[subst -nocommands [lindex $commands $i]]\r"
> >
> > expect {
> >
> > *-re "^\[^\n\r *]*$prompt.*" {}*
> > <<<<
> >
> > * -re "^$altprompt.*>.*" {} *
> > <<<<
> >
> > -re "^\[^\n\r]*$prompt." { exp_continue }
> >
> > -re "(\r\n|\n)" { exp_continue }
> >
> > * -re "\r-- more --\r" { send " "; exp_continue }
> > *
> > <<<<
> >
> > }
> >
> > }
> >
> >
> >
> >
> >
> > ..]
> >
> >
> >
> > I have marked my deviations from “jlogin” with four less than signs.
> >
> >
> >
> > 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:
> >
> >
> >
> > [...
> >
> > infinet;script;rancid -t infinet
> >
> > infinet;login;jlogin
> >
> > infinet;module;infinet
> >
> > infinet;inloop;infinet::inloop
> >
> > infinet;command;infinet::ShowVersion;system version
> >
> > infinet;command;infinet::ShowConfiguration;config show
> >
> > ..]
> >
> >
> >
> > I created an “infinet.pm” based on “mrv.pm”, 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 :
> >
> >
> >
> > 10.12.25.208 <http://10.126.254.208/>: missed cmd(s): all commands
> >
> > 10.12.25.208 <http://10.126.254.208/>: End of run not found
> >
> >
> >
> > >From what I have read it would seem that my issue lies with the “inloop”
> > within my “infinet.pm” 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.
> >
> >
> >
> > 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)
> >
> > DeeTee
>
> > _______________________________________________
> > Rancid-discuss mailing list
> > Rancid-discuss@www.shrubbery.net
> > https://www.shrubbery.net/mailman/listinfo/rancid-discuss
>
>

--
Regards

Daniel Thomas
Re: Trying to backup InfiNet Devices [ In reply to ]
Hi

I need to send you a huge thanks for your help. Your input was critical to
me getting this
bit of work done. In the early hours of this morning RANCID collected the
config of 48 out
of 50 of the InfiNet devices. Will tinker with the last two in the coming
days / weeks.

In order to get the "./rancid -d -t <type>" to work correctly for me I had
to edit the
following two lines in "rancid.types.conf":
infinet;script;rancid -t infinet
infinet;login;infilogin
So that they read as:
infinet;script;./rancid -t infinet
infinet;login;/usr/local/rancid/bin/infilogin

This then meant that my <device>.new and <device>.raw files would populate
and I
was able to troubleshoot the issues that were happening in inLoop. The big
problem
that I was facing was that the "$" in the hostname was being read as a
variable in PERL.

As the RANCID SSH was always the 1st connection the hostname had "$1" at the
end and so PERL was looking at the contents of $1 - which threw off all the
prompt
matches. In trying to remove that (with my poor PERL skills) I stumbled
over
a not so elegant solution of using:
tr/\$/\\/;
In each of the subroutines in the infinet.pm file (just after each
occurence of "tr/\015//d;")
This way the hostname was viewed consistently throughout the script.

After that as we were just looking to grab a plain copy of the config
(which is short
and nice and static) I ended up mostly gutting the sub routines of all the
clever matches
and we got where we needed to be. (might try to tinker and learn about
these in
my own time)

Once again I am very grateful to you for your guidance and support with
this.

All the very best

DeeTee

On Sat, 8 Jan 2022 at 18:36, heasley <heas@shrubbery.net> wrote:

> Fri, Jan 07, 2022 at 10:13:58AM +0000, Daniel Thomas:
> > Thank you very much for your swift response. I will have a look at clogin
> > hlogin (specifically the hpuifilter) to see what I can learn from them.
>
> There are 4 places in hlogin that deal with hpuifilter. should be easy
> to adopt it or even start with that instead. the procurve devices are
> similar to cisco.
>
> > I will also clean up the "$prompt" so that it accepts both versions of
> the
> > prompt.
> >
> > It doesn't appear to be a cmd-line counter - I know that one aspect of
> the
> > behaviour is that the <Dollar Sign><Number> part of the hostname relates
> to
> > how many simultaneous SSH sessions there are. However I cannot understand
> > how on some occasions it "reports back" as not including the <Dollar
> > Sign><Number> suffix. I will play with the debug again and see what I
> get.
>
> I never understand why these prompt things are useful, but ... you want to
> match that whether its there or not. something like this, using the
> hostname generically, $prompt =
>
> '^hostname(\$[0-9]+)?>'
>
> or in expectese
> '^hostname(\\\$\[0-9]+)?>'
>
> forgive me if I dont have the \'s correct.
>
> > I'm reticent to mention this bit as I think it relates to our
> installation
> > of RANCID and the behaviour of the *nix system on which it lives . . but
> > when I have been executing the "rancid -d -t <type>" I get (what I think
> > is) non standard behaviour.
> >
> > If I execute "./rancid -d -t <type>" I get the following behaviour:
> >
> > ./rancid -d -t infinet 10.126.254.208
> >
> >
> >
> > loadtype: device type infinet
> >
> > loadtype: found device type infinet at
> > /usr/local/rancid/etc/rancid.types.conf:119
> >
> > device script (rancid) does not appear to be me (./rancid): exec(rancid
> -t
> > infinet -d 10.126.254.208)
> >
> > Can't exec "rancid": No such file or directory at ./rancid line 104.
> >
> > exec(rancid) failed: No such file or directory
> >
> >
> >
> > And so no .raw nor .new is generated.
> >
> >
> >
> > If I execute
> >
> >
> >
> > perl rancid -d -t infinet 10.126.254.208
> >
> > loadtype: device type infinet
> >
> > loadtype: found device type infinet at
> > /usr/local/rancid/etc/rancid.types.conf:119
> >
> > executing infilogin -t 90 -c"system version;config show" 10.126.254.208
> >
> > 10.126.254.208: missed cmd(s): all commands
> >
> > 10.126.254.208: End of run not found
> >
> > 10.126.254.208: clean_run is false
> >
> > 10.126.254.208: found_end is false
> >
> > !
> >
> >
> >
> > Then raw and new are generated but the .raw then contains:
> >
> >
> >
> > sh: infilogin: command not found
> >
> >
> >
> > Which I understand to be the shell expressing it does not recognise that
> > command. However as mentioned previously everything seems to run fine
> when
> > “rancid-run” is called.
> >
> >
> > I mention this as it hampers me a bit on the more granular
> troubleshooting
> > that is available.
>
> yes; it actually improves troubleshooting :) for me anyway. if you adopt
> the path set in rancid.conf, that should solve this for you. But, it can
> also be manipulated to test local versions, as can evn(PERLV_PATH) be set
> to for local versions of rancid modules.
>
> >
> > Thanks again
> >
> >
> > DeeTee
> >
> >
> > On Thu, 6 Jan 2022 at 22:55, heasley <heas@shrubbery.net> wrote:
> >
> > > Thu, Jan 06, 2022 at 10:23:44PM +0000, Daniel Thomas:
> > > > Hi
> > > >
> > > >
> > > >
> > > > 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.
> > > >
> > > >
> > > >
> > > > 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.
> > > >
> > > > With regards the changing prompt I saw it take the two following
> forms:
> > > > basehostname>
> > > > basehostname$1>
> > > >
> > > > And the trailing characters I saw were:
> > > >
> > > > \r\u001b[.16C\u001b[.K\r\u001b[.16C
> > > >
> > > > 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”
> > >
> > > You might look at clogin; the EXOS also has a command line counter.
> Is it
> > > a cmd-line counter?
> > >
> > > And, look at hlogin, which uses hpuifilter to remove most of the screen
> > > manipulation escape codes. Sometimes a more rudimentary TERM type
> causes
> > > devices no use the escape codes; like 'network' or 'dumb'. there are
> at
> > > least 2 *.pm's that do this.
> > >
> > > I think that if you combine these two methods, it will be easier. copy
> > > clogin and modify for the prompt alternatives, add the hpuifilter
> changes
> > > from hlogin.
> > >
> > > if thats not attractive, debug the missed commands with rancid -d -t
> <type>
> > > looking for the command matches. I expect there will be none and the
> *.new
> > > file will be empty. Compare the prompt matchine in inloop() to whats
> in
> > > the *.raw file and look for escape codes in the prompts within the
> *.raw
> > > file.
> > >
> > > below, I would just alter $prompt to accept either version of the
> prompt.
> > > That will make it easier (more consistent with other scripts) for -x or
> > > -s.
> > >
> > > > [...
> > > >
> > > >
> > > >
> > > > # we are logged in, now figure out the full prompt
> > > >
> > > > send "\r"
> > > >
> > > > expect {
> > > >
> > > > -re "(\r\n|\n)" { exp_continue; }
> > > >
> > > > -re "^\[^ ]+$prompt" { set prompt $expect_out(0,string);
> > > >
> > > > *regsub ">" $prompt ">" prompt;
> > > > *
> > > > <<<<
> > > >
> > > > }
> > > >
> > > > }
> > > >
> > > > # send $prompt
> > > >
> > > > set in_proc 0
> > > >
> > > > return 0
> > > >
> > > > }
> > > >
> > > >
> > > >
> > > > # Run commands given on the command line.
> > > >
> > > > proc run_commands { prompt command } {
> > > >
> > > > global do_interact in_proc
> > > >
> > > > set in_proc 1
> > > >
> > > >
> > > >
> > > > * set altprompt [string range $prompt 0 11] *
> > > > <<<<
> > > >
> > > > # handle escaped ;s in commands, and ;; and ^;
> > > >
> > > > regsub -all {([^\\]);} $command \\1\u0002; esccommand
> > > >
> > > > regsub -all {([^\\]);;} $esccommand \\1;\u0002; command
> > > >
> > > > regsub {^;} $command "\u0002;" esccommand
> > > >
> > > > regsub -all {[\\];} $esccommand ";" command
> > > >
> > > > regsub -all {\u0002;} $command "\u0002" esccommand
> > > >
> > > > set sep "\u0002"
> > > >
> > > > set commands [split $esccommand $sep]
> > > >
> > > > set num_commands [llength $commands]
> > > >
> > > > for {set i 0} {$i < $num_commands} { incr i} {
> > > >
> > > > send -- "[subst -nocommands [lindex $commands $i]]\r"
> > > >
> > > > expect {
> > > >
> > > > *-re "^\[^\n\r *]*$prompt.*" {}*
> > > > <<<<
> > > >
> > > > * -re "^$altprompt.*>.*" {} *
> > > > <<<<
> > > >
> > > > -re "^\[^\n\r]*$prompt." { exp_continue }
> > > >
> > > > -re "(\r\n|\n)" { exp_continue }
> > > >
> > > > * -re "\r-- more --\r" { send " "; exp_continue }
> > > > *
> > > > <<<<
> > > >
> > > > }
> > > >
> > > > }
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > ..]
> > > >
> > > >
> > > >
> > > > I have marked my deviations from “jlogin” with four less than signs.
> > > >
> > > >
> > > >
> > > > 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:
> > > >
> > > >
> > > >
> > > > [...
> > > >
> > > > infinet;script;rancid -t infinet
> > > >
> > > > infinet;login;jlogin
> > > >
> > > > infinet;module;infinet
> > > >
> > > > infinet;inloop;infinet::inloop
> > > >
> > > > infinet;command;infinet::ShowVersion;system version
> > > >
> > > > infinet;command;infinet::ShowConfiguration;config show
> > > >
> > > > ..]
> > > >
> > > >
> > > >
> > > > I created an “infinet.pm” based on “mrv.pm”, 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 :
> > > >
> > > >
> > > >
> > > > 10.12.25.208 <http://10.126.254.208/>: missed cmd(s): all commands
> > > >
> > > > 10.12.25.208 <http://10.126.254.208/>: End of run not found
> > > >
> > > >
> > > >
> > > > >From what I have read it would seem that my issue lies with the
> “inloop”
> > > > within my “infinet.pm” 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.
> > > >
> > > >
> > > >
> > > > 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)
> > > >
> > > > DeeTee
> > >
> > > > _______________________________________________
> > > > Rancid-discuss mailing list
> > > > Rancid-discuss@www.shrubbery.net
> > > > https://www.shrubbery.net/mailman/listinfo/rancid-discuss
> > >
> > >
> >
> > --
> > Regards
> >
> > Daniel Thomas
>


--
Regards

Daniel Thomas
Re: Trying to backup InfiNet Devices [ In reply to ]
Wed, Jan 12, 2022 at 09:40:08PM +0000, Daniel Thomas:
> In order to get the "./rancid -d -t <type>" to work correctly for me I had
> to edit the
> following two lines in "rancid.types.conf":
> infinet;script;rancid -t infinet
> infinet;login;infilogin
> So that they read as:
> infinet;script;./rancid -t infinet
> infinet;login;/usr/local/rancid/bin/infilogin

Assuming that directory is in rancid.conf:PATH, it does not have to be
a FQPN here. it can be though, obviously.

> This then meant that my <device>.new and <device>.raw files would populate
> and I
> was able to troubleshoot the issues that were happening in inLoop. The big
> problem
> that I was facing was that the "$" in the hostname was being read as a
> variable in PERL.
>
> As the RANCID SSH was always the 1st connection the hostname had "$1" at the
> end and so PERL was looking at the contents of $1 - which threw off all the
> prompt
> matches. In trying to remove that (with my poor PERL skills) I stumbled
> over
> a not so elegant solution of using:
> tr/\$/\\/;
> In each of the subroutines in the infinet.pm file (just after each
> occurence of "tr/\015//d;")
> This way the hostname was viewed consistently throughout the script.

Not sure that I follow, but if it works in all the permutation of the
prompt, great. I suspect this might be the problem with your 2 failing
devices. maybe discard the tail of the prompt, escape any regex atoms,
and append the aforementioned regex like:

if (!defined($prompt)) {
$prompt = ($_ =~ /^([^#>$]+)(\$\d+)?[#>]/)[0];
$prompt =~ s/([][}{)(+\\])/\\$1/g;
$prompt .= "(\$\d+)?[#>]";

print STDERR ("PROMPT MATCH: $prompt\n") if ($debug);
}

prost

_______________________________________________
Rancid-discuss mailing list
Rancid-discuss@www.shrubbery.net
https://www.shrubbery.net/mailman/listinfo/rancid-discuss