Discussion:
[rancid] figure out prompt in h3clogin fails
Stefan Juon
2010-03-25 07:37:14 UTC
Permalink
Hi all
I try to make rancid working for h3c/3com switches. Therefore I got the
appropriate enhancements from
http://sites.google.com/site/jrbinks/code/rancid/h3c. I can login to a
switch using h3clogin, no problem. But once expect should figure out the
prompt it hangs. Here is an example of sending the command "dis device" to a
switch called npd0011:

***@sksch001:~$ h3clogin -autoenable -t 5 -c "dis device" npd0011
npd0011
spawn ssh -c 3des -x -l rancid npd0011
***@npd0011's password:

<npd0011>undo terminal monitor
Info: Current terminal monitor is off.

<npd0011>
<npd0011>
Error: TIMEOUT reached


I firstly did some tries using the options autoenable and noenable, without
any success. In the expect script h3clogin I noticed this section:



# we are logged in, now figure out the full prompt
send "\r"
expect {
-re "\[\r\n]+" { exp_continue; }
# -re "^(.+:)1 $prompt" { # stoopid extreme cmd-line numbers and
# # prompt based on state of config changes,
# # which may have an * at the beginning.
# h3c:
# send_user "% test\r"
# set junk $expect_out(1,string)
# regsub -all "^\\\* " $expect_out(1,string)
{} junk
# set prompt ".? ?$junk\[0-9]+
$expect_out(2,string)";
# set platform "extreme"
# }
-re "^.+$prompt" { set junk $expect_out(0,string);
regsub -all "\[\]\[]" $junk {\\&} prompt;
}
-re "^.+> \\\(enable\\\)" {
set junk $expect_out(0,string);
regsub -all "\[\]\[]" $junk {\\&} prompt;
}
}


I used to use expect in the past but this is far away...from my
understanding we send a \r and as a next step we try to determine the
prompt, which obviously failes. Any ideas?

Rgs, Stefan
Jethro R Binks
2010-03-25 18:34:01 UTC
Permalink
Post by Stefan Juon
I try to make rancid working for h3c/3com switches. Therefore I got the
appropriate enhancements from
http://sites.google.com/site/jrbinks/code/rancid/h3c. I can login to a
switch using h3clogin, no problem. But once expect should figure out the
prompt it hangs. Here is an example of sending the command "dis device" to a
Hi Stefan,

I wrote this code, a long time ago. I haven't looked at it in ages, but
it works day-to-day for me. However, when I wrote it I only had 3Com 5500
models. I've now got something else plus some more models to come soon,
but I've not tested against them yet. What model were you trying this
against?

I'll do some more tests later.

In the meantime, the usual method for debugging would be something like:

env NOPIPE=y PATH=${PATH}:/usr/local/libexec/rancid h3crancid -d devicename

which will create a .new and a .raw file without output in your working
directory.

Jethro.



. . . . . . . . . . . . . . . . . . . . . . . . .
Jethro R Binks
Computing Officer, IT Services, University Of Strathclyde, Glasgow, UK
Stefan Juon
2010-03-26 08:43:16 UTC
Permalink
Post by Jethro R Binks
Hi Stefan,
I wrote this code, a long time ago. I haven't looked at it in ages, but
it works day-to-day for me. However, when I wrote it I only had 3Com 5500
models. I've now got something else plus some more models to come soon,
but I've not tested against them yet. What model were you trying this
against?>
I'll do some more tests later.
env NOPIPE=y PATH=${PATH}:/usr/local/libexec/rancid h3crancid -d devicename
which will create a .new and a .raw file without output in your working
directory.
Jethro.
Nice to meet u Jethro and thank you for you effort for h3clogin ;-)
I try to make rancid work against a H3C S5120 (and furthermore a
S7500E, S5800). Once I set NOPIPE=y the .new and .raw are touched.
However there is no new information:

.new:
!RANCID-CONTENT-TYPE: h3c
!

.raw:
npd0011
spawn ssh -c 3des -x -l rancid npd0011
***@npd0011's password:

<npd0011>undo terminal monitor
Info: Current terminal monitor is off.

<npd0011>
<npd0011>
Error: TIMEOUT reached

Am I right the after sending \r the prompt is automaticlly determined?

Stefan
Jethro R Binks
2010-03-28 19:34:25 UTC
Permalink
(I wrote this but did not send it at the time; subsequently I have sent
Stefan a new version to try which fixes some issues).
Nice to meet u Jethro and thank you for you effort for h3clogin ;-) I
try to make rancid work against a H3C S5120 (and furthermore a S7500E,
S5800). Once I set NOPIPE=y the .new and .raw are touched. However there
!RANCID-CONTENT-TYPE: h3c
!
npd0011
spawn ssh -c 3des -x -l rancid npd0011
<npd0011>undo terminal monitor
Info: Current terminal monitor is off.
<npd0011>
<npd0011>
Error: TIMEOUT reached
Am I right the after sending \r the prompt is automaticlly determined?
Something like that, but it can be very fragile across different boxes.

I have a question: I have one (3Com-branded) 4800G (apparently the same as
the H3C-branded S5500, but not the same as the 3Com-branded 5500) which
issues bell (ding!) when it prints the prompt. Does your model happen to
do this?

I will be away next week so may not get to look at this any more.

Jethro.


. . . . . . . . . . . . . . . . . . . . . . . . .
Jethro R Binks
Computing Officer, IT Services, University Of Strathclyde, Glasgow, UK
Loading...