[rancid] figure out prompt in h3clogin fails

Stefan Juon sjuon74 at gmail.com
Thu Mar 25 07:37:14 UTC 2010


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:

rancid at sksch001:~$ h3clogin -autoenable -t 5 -c "dis device" npd0011
npd0011
spawn ssh -c 3des -x -l rancid npd0011
rancid at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.shrubbery.net/pipermail/rancid-discuss/attachments/20100325/c68e9854/attachment.html 


More information about the Rancid-discuss mailing list