Discussion:
[rancid] SSH issues "couldn't compile regular expression pattern: parentheses () not balanced"
Sylvain 74
2010-06-22 17:17:23 UTC
Permalink
Hi everyone,

I can't connect to my HP Procurve 2625 nor 2524 using SSH. Telnet is ok as you can see :

----------------------TELNET CONNEXION OK------------------
[***@erf ~]$ bin/hlogin -f .cloginrc -c "sh version" lapphpsw27
lapphpsw27
spawn hpuifilter -- telnet lapphpsw27
Trying 134.xxx.xxx.xx...
Connected to lapphpsw27.xxxxx.xx (134.xxx.xxx.xx).
Escape character is '^]'.
ProCurve J4900B Switch 2626
Software revision H.10.50

Copyright (C) 1991-2007 Hewlett-Packard Co. All Rights Reserved.

RESTRICTED RIGHTS LEGEND

Use, duplication, or disclosure by the Government is subject to restrictions
as set forth in subdivision (b) (3) (ii) of the Rights in Technical Data and
Computer Software clause at 52.227-7013.

HEWLETT-PACKARD COMPANY, 3000 Hanover St., Palo Alto, CA 94303

Press any key to continueUsername: manager
Password:
hpsh27#
hpsh27# no page
hpsh27# sh version
Image stamp: /sw/code/build/fish(mkfs)
Oct 9 2007 15:00:51
H.10.50
359
Boot Image: Primary
hpsh27#exit
hpsh27> exit
Do you want to log out [y/n]? y

Connection closed by foreign host.
-----------------------------------------------------------

When I run the same command using "add method ssh" in config file :

-------------------SSH CONNEXION FAILED--------------------
[***@erf ~]$ bin/hlogin -f .cloginrc -c "sh version" lapphpsw27
lapphpsw27
spawn ssh -c 3des -x -l manager lapphpsw27
***@lapphpsw27's password:
ProCurve J4900B Switch 2626
Software revision H.10.50

Copyright (C) 1991-2007 Hewlett-Packard Co. All Rights Reserved.

RESTRICTED RIGHTS LEGEND

Use, duplication, or disclosure by the Government is subject to restrictions
as set forth in subdivision (b) (3) (ii) of the Rights in Technical Data and
Computer Software clause at 52.227-7013.

HEWLETT-PACKARD COMPANY, 3000 Hanover St., Palo Alto, CA 94303


Press any key to continue

hpsh27#
hpsh27# couldn't compile regular expression pattern: parentheses () not balanced
while executing
[^#>\r\n]+)?[#>](\([^)\r\n]+\))?} {} -re {[
]+} { exp_continue }"
invoked from within
"expect {
-re $reprompt {}
-re "\[\n\r]+" { exp_continue }
}"
(procedure "run_commands" line 9)
invoked from within
"run_commands $prompt $command"
("foreach" body line 148)
invoked from within
"foreach router [lrange $argv $i end] {
set router [string tolower $router]
send_user "$router\n"

# device timeout
set timeout [find t..."
(file "bin/hlogin" line 594)
[***@erf ~]$
-----------------------------------------------------------

My .cloginrc file :
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
add user lapphpsw27 {xxxxx}
add password lapphpsw27 {xxxx} {xxxx}
add method lapphpsw27 ssh
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


The problem seems to be localised line 505 in hlogin :
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Turn off the pager and escape regex meta characters in the $prompt
send "no page\r"
regsub -all {[)(]} $prompt {\\&} reprompt
-> regsub -all {^(.{1,11}).*([#>])$} $reprompt {\1([^#>\r\n]+)?[#>](\\([^)\\r\\n]+\\))?} reprompt
expect {
-re $reprompt {}
-re "\[\n\r]+" { exp_continue }
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If I replace this line by
-> regsub -all {^(.{1,11}).*([#>])$} $reprompt {\1] reprompt
then SSH seems to be ok but it closes strangely :

----------------SSH WITH LINE 505 MODIFIED-----------
[***@erf ~]$ bin/hlogin -f .cloginrc -c "sh version" lapphpsw27
lapphpsw27
spawn ssh -c 3des -x -l manager lapphpsw27
***@lapphpsw27's password:
ProCurve J4900B Switch 2626
Software revision H.10.50

Copyright (C) 1991-2007 Hewlett-Packard Co. All Rights Reserved.

RESTRICTED RIGHTS LEGEND

Use, duplication, or disclosure by the Government is subject to restrictions
as set forth in subdivision (b) (3) (ii) of the Rights in Technical Data and
Computer Software clause at 52.227-7013.

HEWLETT-PACKARD COMPANY, 3000 Hanover St., Palo Alto, CA 94303


Press any key to continue


hpsh27# no page
hpsh27# sh version
Image stamp: /sw/code/build/fish(mkfs)
Oct 9 2007 15:00:51
H.10.50
359
Boot Image: Primary
hpsh27# [xit9He
hpsh27> exit
Do you want to log out [y/n]? y
------------------------------------------------------------

As you can see the "exit" before logout is messed up.
I would love to correct this line in hlogin (line 505), but I fear I'm not able to do that.

Rancid v2.3.3
Expect v5.42.1
SSH is ok when I log in manually on my HP switches.
The error message is exactly the same when using clogin with HP switches.
I don't have any problem when I connect to cisco switches using clogin and SSH.

Any suggestion ?


sylvain;


PS : Thanks all for your job, this soft is simply awesome !
Per-Olof Olsson
2010-06-23 05:10:00 UTC
Permalink
Hi


Missing hpuifilter in hlogin 2.3.3 for ssh.


< set retval [ catch {eval spawn [split "$cmd -c $cyphertype
-x -l $user $router" { }]} reason ]
---
set retval [ catch {eval spawn hpuifilter -- [split "$cmd -c
$cyphertype -x -l $user $router" { }]} reason ]


more info from old subject/case
"[rancid] Re: Rancid stopped working for my HP switches"
from 04/03/2010
Hi everyone,
----------------------TELNET CONNEXION OK------------------
lapphpsw27
spawn hpuifilter -- telnet lapphpsw27
Trying 134.xxx.xxx.xx...
Connected to lapphpsw27.xxxxx.xx (134.xxx.xxx.xx).
Escape character is '^]'.
ProCurve J4900B Switch 2626
Software revision H.10.50
Copyright (C) 1991-2007 Hewlett-Packard Co. All Rights Reserved.
RESTRICTED RIGHTS LEGEND
Use, duplication, or disclosure by the Government is subject to restrictions
as set forth in subdivision (b) (3) (ii) of the Rights in Technical Data and
Computer Software clause at 52.227-7013.
HEWLETT-PACKARD COMPANY, 3000 Hanover St., Palo Alto, CA 94303
Press any key to continueUsername: manager
hpsh27#
hpsh27# no page
hpsh27# sh version
Image stamp: /sw/code/build/fish(mkfs)
Oct 9 2007 15:00:51
H.10.50
359
Boot Image: Primary
hpsh27#exit
hpsh27> exit
Do you want to log out [y/n]? y
Connection closed by foreign host.
-----------------------------------------------------------
-------------------SSH CONNEXION FAILED--------------------
lapphpsw27
spawn ssh -c 3des -x -l manager lapphpsw27
ProCurve J4900B Switch 2626
Software revision H.10.50
Copyright (C) 1991-2007 Hewlett-Packard Co. All Rights Reserved.
RESTRICTED RIGHTS LEGEND
Use, duplication, or disclosure by the Government is subject to restrictions
as set forth in subdivision (b) (3) (ii) of the Rights in Technical Data and
Computer Software clause at 52.227-7013.
HEWLETT-PACKARD COMPANY, 3000 Hanover St., Palo Alto, CA 94303
Press any key to continue
hpsh27#
hpsh27# couldn't compile regular expression pattern: parentheses () not balanced
while executing
[^#>\r\n]+)?[#>](\([^)\r\n]+\))?} {} -re {[
]+} { exp_continue }"
invoked from within
"expect {
-re $reprompt {}
-re "\[\n\r]+" { exp_continue }
}"
(procedure "run_commands" line 9)
invoked from within
"run_commands $prompt $command"
("foreach" body line 148)
invoked from within
"foreach router [lrange $argv $i end] {
set router [string tolower $router]
send_user "$router\n"
# device timeout
set timeout [find t..."
(file "bin/hlogin" line 594)
-----------------------------------------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
add user lapphpsw27 {xxxxx}
add password lapphpsw27 {xxxx} {xxxx}
add method lapphpsw27 ssh
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Turn off the pager and escape regex meta characters in the $prompt
send "no page\r"
regsub -all {[)(]} $prompt {\\&} reprompt
-> regsub -all {^(.{1,11}).*([#>])$} $reprompt {\1([^#>\r\n]+)?[#>](\\([^)\\r\\n]+\\))?} reprompt
expect {
-re $reprompt {}
-re "\[\n\r]+" { exp_continue }
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If I replace this line by
-> regsub -all {^(.{1,11}).*([#>])$} $reprompt {\1] reprompt
----------------SSH WITH LINE 505 MODIFIED-----------
lapphpsw27
spawn ssh -c 3des -x -l manager lapphpsw27
ProCurve J4900B Switch 2626
Software revision H.10.50
Copyright (C) 1991-2007 Hewlett-Packard Co. All Rights Reserved.
RESTRICTED RIGHTS LEGEND
Use, duplication, or disclosure by the Government is subject to restrictions
as set forth in subdivision (b) (3) (ii) of the Rights in Technical Data and
Computer Software clause at 52.227-7013.
HEWLETT-PACKARD COMPANY, 3000 Hanover St., Palo Alto, CA 94303
Press any key to continue
hpsh27# no page
hpsh27# sh version
Image stamp: /sw/code/build/fish(mkfs)
Oct 9 2007 15:00:51
H.10.50
359
Boot Image: Primary
hpsh27# [xit9He
hpsh27> exit
Do you want to log out [y/n]? y
------------------------------------------------------------
As you can see the "exit" before logout is messed up.
I would love to correct this line in hlogin (line 505), but I fear I'm not able to do that.
Rancid v2.3.3
Expect v5.42.1
SSH is ok when I log in manually on my HP switches.
The error message is exactly the same when using clogin with HP switches.
I don't have any problem when I connect to cisco switches using clogin and SSH.
Any suggestion ?
sylvain;
PS : Thanks all for your job, this soft is simply awesome !
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
/Peo
----------------------------------------------------------
Per-Olof Olsson Email: ***@chalmers.se
Chalmers tekniska högskola IT-service
Hörsalsvägen 5 412 96 Göteborg
Tel: 031/772 6738 Fax: 031/772 8660
----------------------------------------------------------
Sylvain 74
2010-06-24 09:43:16 UTC
Permalink
Hi,
Objet: Re: [rancid] SSH issues "couldn't compile regular expression pattern: parentheses () not balanced"
Date: Mercredi 23 juin 2010, 7h10
Hi
Missing hpuifilter in hlogin 2.3.3 for ssh.
<           set
retval [ catch {eval spawn [split "$cmd -c $cyphertype
-x -l $user $router" { }]} reason ]
---
           set
retval [ catch {eval spawn hpuifilter -- [split "$cmd -c
$cyphertype -x -l $user $router" { }]} reason ]
more info from old subject/case
"[rancid] Re: Rancid stopped working for my HP switches"
from 04/03/2010
Following this case I downloaded heas's patched version (threaded on Apr 8, 2010) and I applyed patches you suggest in the last thread.
It seems to works perfectly now.
Thanks a lot !

s.
Hi everyone,
I can't connect to my HP Procurve 2625 nor 2524 using
----------------------TELNET CONNEXION
OK------------------
version" lapphpsw27
lapphpsw27
spawn hpuifilter -- telnet lapphpsw27
Trying 134.xxx.xxx.xx...
Connected to lapphpsw27.xxxxx.xx (134.xxx.xxx.xx).
Escape character is '^]'.
ProCurve J4900B Switch 2626
Software revision H.10.50
Copyright (C) 1991-2007 Hewlett-Packard Co.  All
Rights Reserved.
               
            RESTRICTED RIGHTS
LEGEND
  Use, duplication, or disclosure by the
Government is subject to restrictions
  as set forth in subdivision (b) (3) (ii) of the
Rights in Technical Data and
  Computer Software clause at 52.227-7013.
          HEWLETT-PACKARD
COMPANY, 3000 Hanover St., Palo Alto, CA 94303
Press any key to continueUsername: manager
hpsh27#
hpsh27# no page
hpsh27#  sh version
Image stamp:    /sw/code/build/fish(mkfs)
             
   Oct  9 2007 15:00:51
             
   H.10.50
             
   359
Boot Image:     Primary
hpsh27#exit
hpsh27> exit
Do you want to log out [y/n]? y
Connection closed by foreign host.
-----------------------------------------------------------
When I run the same command using "add method ssh" in
-------------------SSH CONNEXION
FAILED--------------------
version" lapphpsw27           
               
               
               
       
lapphpsw27
spawn ssh -c 3des -x -l manager lapphpsw27
ProCurve J4900B Switch 2626
Software revision H.10.50
Copyright (C) 1991-2007 Hewlett-Packard Co.  All
Rights Reserved.
               
            RESTRICTED RIGHTS
LEGEND
  Use, duplication, or disclosure by the
Government is subject to restrictions
  as set forth in subdivision (b) (3) (ii) of the
Rights in Technical Data and
  Computer Software clause at 52.227-7013.
          HEWLETT-PACKARD
COMPANY, 3000 Hanover St., Palo Alto, CA 94303
Press any key to continue
hpsh27#
parentheses () not balanced
     while executing
[^#>\r\n]+)?[#>](\([^)\r\n]+\))?} {} -re {[
]+} { exp_continue }"
     invoked from within
"expect {
         -re
$reprompt   {}
         -re
"\[\n\r]+"  { exp_continue }
     }"
     (procedure "run_commands" line
9)
     invoked from within
"run_commands $prompt $command"
     ("foreach" body line 148)
     invoked from within
"foreach router [lrange $argv $i end] {
     set router [string tolower
$router]
     send_user "$router\n"
     # device timeout
     set timeout [find t..."
     (file "bin/hlogin" line 594)
-----------------------------------------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
add user lapphpsw27     {xxxxx}
add password lapphpsw27 {xxxx} {xxxx}
add method lapphpsw27   ssh
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The problem seems to be localised line 505 in hlogin
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     # Turn off the pager and
escape regex meta characters in the $prompt
     send "no page\r"
     regsub -all {[)(]} $prompt
{\\&} reprompt
->  regsub -all {^(.{1,11}).*([#>])$}
$reprompt {\1([^#>\r\n]+)?[#>](\\([^)\\r\\n]+\\))?}
reprompt
     expect {
         -re
$reprompt   {}
         -re
"\[\n\r]+"  { exp_continue }
     }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If I replace this line by
->  regsub -all {^(.{1,11}).*([#>])$}
$reprompt {\1] reprompt
----------------SSH WITH LINE 505 MODIFIED-----------
version" lapphpsw27
lapphpsw27
spawn ssh -c 3des -x -l manager lapphpsw27
ProCurve J4900B Switch 2626
Software revision H.10.50
Copyright (C) 1991-2007 Hewlett-Packard Co.  All
Rights Reserved.
               
            RESTRICTED RIGHTS
LEGEND
  Use, duplication, or disclosure by the
Government is subject to restrictions
  as set forth in subdivision (b) (3) (ii) of the
Rights in Technical Data and
  Computer Software clause at 52.227-7013.
          HEWLETT-PACKARD
COMPANY, 3000 Hanover St., Palo Alto, CA 94303
Press any key to continue
hpsh27# no page
hpsh27# sh version
Image stamp:    /sw/code/build/fish(mkfs)
             
   Oct  9 2007 15:00:51
             
   H.10.50
             
   359
Boot Image:     Primary
hpsh27# [xit9He
hpsh27> exit
Do you want to log out [y/n]? y
------------------------------------------------------------
As you can see the "exit" before logout is messed up.
I would love to correct this line in hlogin (line
505), but I fear I'm not able to do that.
Rancid v2.3.3
Expect v5.42.1
SSH is ok when I log in manually on my HP switches.
The error message is exactly the same when using
clogin with HP switches.
I don't have any problem when I connect to cisco
switches using clogin and SSH.
Any suggestion ?
sylvain;
PS : Thanks all for your job, this soft is simply
awesome !
       
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
/Peo
----------------------------------------------------------
Per-Olof Olsson           
Chalmers tekniska högskola    IT-service
Hörsalsvägen 5           
    412 96 Göteborg
Tel: 031/772 6738  Fax: 031/772 8660
----------------------------------------------------------
Loading...