Discussion:
[rancid] expect script help
Brian Lam
2010-01-28 21:05:00 UTC
Permalink
This is a very simple question. Sorry if it was asked somewhere else.

I ran '/usr/local/rancid/bin/rancid-run' and noticed that it hung. I
debugged and found the issue:

The expect / python script /usr/local/rancid/bin/clogin was looping because
my router doesn't like 'exit' and prefer 'quit'.

It's an old force10 router. Our new forc10 router works fine.

I am afraid to touch clogin or f10rancid w/o some guidance.

Any help would be appreciated.
--
Brian Lam | IT/Operations | Rockyou, Inc. | Phone: 408-425-9801 | AIM:
brianclam2
Martin Barry
2010-01-29 14:00:44 UTC
Permalink
$quoted_author = "Brian Lam" ;
Post by Brian Lam
The expect / python script /usr/local/rancid/bin/clogin was looping because
my router doesn't like 'exit' and prefer 'quit'.
You can either modify the following to match the 'force10' platform (does
the newer one accept quit?)

# line 678
if { [ string compare "extreme" "$platform" ] } {
send -h "exit\r"
} else {
send -h "quit\r"
}


or you could add a stanza in the next section to catch the error thrown when
sending 'exit' to old force10.

cheers
Marty
Brian Lam
2010-01-29 18:32:00 UTC
Permalink
thank you. i should be able to figure out from here. i will let you know.
Post by Martin Barry
$quoted_author = "Brian Lam" ;
Post by Brian Lam
The expect / python script /usr/local/rancid/bin/clogin was looping
because
Post by Brian Lam
my router doesn't like 'exit' and prefer 'quit'.
You can either modify the following to match the 'force10' platform (does
the newer one accept quit?)
# line 678
if { [ string compare "extreme" "$platform" ] } {
send -h "exit\r"
} else {
send -h "quit\r"
}
or you could add a stanza in the next section to catch the error thrown when
sending 'exit' to old force10.
cheers
Marty
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
--
Brian Lam | IT/Operations | Rockyou, Inc. | Phone: 408-425-9801 | AIM:
brianclam2
Brian Lam
2010-02-02 10:40:54 UTC
Permalink
Post by Martin Barry
$quoted_author = "Brian Lam" ;
Post by Brian Lam
The expect / python script /usr/local/rancid/bin/clogin was looping
because
Post by Brian Lam
my router doesn't like 'exit' and prefer 'quit'.
You can either modify the following to match the 'force10' platform (does
the newer one accept quit?)
the new f10 version accepts 'quit'
Post by Martin Barry
# line 678
if { [ string compare "extreme" "$platform" ] } {
send -h "exit\r"
} else {
send -h "quit\r"
}
my version of rancid is 2.3.2

per your recommendation, here's the diff:

EQX ***@itops1a:/usr/local/rancid/bin# diff clogin clogin.original
662,664c662
< if { [ string compare "force10" "$platform" ] } {
< send -h "quit\r"
< } elseif { [ string compare "extreme" "$platform" ] } {
---
Post by Martin Barry
if { [ string compare "extreme" "$platform" ] } {
EQX ***@itops1a:/usr/local/rancid/bin#

it's a case of fixing one thing and another breaks...

it looks like it's not looping anymore but it's not updating any of the f10
switches (the previous working f10 are not updated either). rancid log shows
the following for all force10 router:
(maybe because the output is different now, rancid end regex doesn't work
anymore?)

=====================================
Getting missed routers: round 1.
r103: End of run not found
end
r103-2: End of run not found
end
r205-sw1: End of run not found
end
ec1: End of run not found
end
ec2: End of run not found
end
r304: End of run not found
end
r304-2: End of run not found
end
=====================================
Post by Martin Barry
or you could add a stanza in the next section to catch the error thrown when
sending 'exit' to old force10.
maybe i will target the stanza instead and have better luck. the loop
output is below. the first 'exit' works but the 2nd on throws an error '%
Invalid input detected at '^' marker.'

could you help point me to the right place where i can write an expect
regexp to capture this error and deal with it? many thanks. spend many hr
pulling my hair / debugging! :p btw, is their a debug flag that i can set
to get more debug outputs?



(looping output)

interface vlan 1
exit



exit
end

r204-sw1#exit

r204-sw1>exit
^
% Invalid input detected at '^' marker.

r204-sw1>exit
^
% Invalid input detected at '^' marker.

r204-sw1>exit
^
% Invalid input detected at '^' marker.

r204-sw1>exit
^

(looping...)
Post by Martin Barry
cheers
Marty
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
--
Brian Lam | IT/Operations | Rockyou, Inc. | Phone: 408-425-9801 | AIM:
brianclam2
Brian Lam
2010-02-02 10:55:39 UTC
Permalink
i found the debug flag. here's the output during the loop:
(i will try to trace it down in the code and see if i can set a condition
for this...)

r204-sw1>
expect: does " ^\r\n% Invalid input detected at '^'
marker.\r\n\r\nr204-sw1>" (spawn_id exp6) match regular expression "^[^\n\r
*]*r204-sw1([^#>\r\n]+)?[#>](\([^)\r\n]+\))?"? no
"The system has unsaved changes"? no
"Would you like to save them now"? no
"(Profile|Configuration) changes have occurred.*"? no
"Do you wish to save your configuration changes"? no
"[\n\r]+"? yes
expect: set expect_out(0,string) "\r\n"
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) " ^\r\n"
expect: continuing expect

expect: does "% Invalid input detected at '^' marker.\r\n\r\nr204-sw1>"
(spawn_id exp6) match regular expression "^[^\n\r
*]*r204-sw1([^#>\r\n]+)?[#>](\([^)\r\n]+\))?"? no
"The system has unsaved changes"? no
"Would you like to save them now"? no
"(Profile|Configuration) changes have occurred.*"? no
"Do you wish to save your configuration changes"? no
"[\n\r]+"? yes
expect: set expect_out(0,string) "\r\n\r\n"
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) "% Invalid input detected at '^'
marker.\r\n\r\n"
expect: continuing expect

expect: does "r204-sw1>" (spawn_id exp6) match regular expression "^[^\n\r
*]*r204-sw1([^#>\r\n]+)?[#>](\([^)\r\n]+\))?"? yes
expect: set expect_out(0,string) "r204-sw1>"
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) "r204-sw1>"
send: sending "exit\r" to { exp6 human_write: avg_arr=0.400000/0.400000
1/shape=1.428571 min=0.300000 max=5.000000


sighandler: handling signal(2)
async event handler: Tcl_Eval(exit 130)



write() failed to write anything - will sleep(1) and retry...
Post by Brian Lam
Post by Martin Barry
$quoted_author = "Brian Lam" ;
Post by Brian Lam
The expect / python script /usr/local/rancid/bin/clogin was looping
because
Post by Brian Lam
my router doesn't like 'exit' and prefer 'quit'.
You can either modify the following to match the 'force10' platform (does
the newer one accept quit?)
the new f10 version accepts 'quit'
Post by Martin Barry
# line 678
if { [ string compare "extreme" "$platform" ] } {
send -h "exit\r"
} else {
send -h "quit\r"
}
my version of rancid is 2.3.2
662,664c662
< if { [ string compare "force10" "$platform" ] } {
< send -h "quit\r"
< } elseif { [ string compare "extreme" "$platform" ] } {
---
Post by Martin Barry
if { [ string compare "extreme" "$platform" ] } {
it's a case of fixing one thing and another breaks...
it looks like it's not looping anymore but it's not updating any of the f10
switches (the previous working f10 are not updated either). rancid log shows
(maybe because the output is different now, rancid end regex doesn't work
anymore?)
=====================================
Getting missed routers: round 1.
r103: End of run not found
end
r103-2: End of run not found
end
r205-sw1: End of run not found
end
ec1: End of run not found
end
ec2: End of run not found
end
r304: End of run not found
end
r304-2: End of run not found
end
=====================================
Post by Martin Barry
or you could add a stanza in the next section to catch the error thrown when
sending 'exit' to old force10.
maybe i will target the stanza instead and have better luck. the loop
output is below. the first 'exit' works but the 2nd on throws an error '%
Invalid input detected at '^' marker.'
could you help point me to the right place where i can write an expect
regexp to capture this error and deal with it? many thanks. spend many hr
pulling my hair / debugging! :p btw, is their a debug flag that i can set
to get more debug outputs?
(looping output)
interface vlan 1
exit
exit
end
r204-sw1#exit
r204-sw1>exit
^
% Invalid input detected at '^' marker.
r204-sw1>exit
^
% Invalid input detected at '^' marker.
r204-sw1>exit
^
% Invalid input detected at '^' marker.
r204-sw1>exit
^
(looping...)
Post by Martin Barry
cheers
Marty
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
--
brianclam2
--
Brian Lam | IT/Operations | Rockyou, Inc. | Phone: 408-425-9801 | AIM:
brianclam2
Martin Barry
2010-02-03 16:05:51 UTC
Permalink
$quoted_author = "Brian Lam" ;
Post by Brian Lam
it looks like it's not looping anymore but it's not updating any of the f10
switches (the previous working f10 are not updated either). rancid log shows
I think it might be because it has a two stage "quit" rather than just
needing a different command.
Post by Brian Lam
maybe i will target the stanza instead and have better luck. the loop
output is below. the first 'exit' works but the 2nd on throws an error '%
Invalid input detected at '^' marker.'
Try something like

"Invalid input detected at" { # F10 two stage quit
send -h "quit\r"
exp_continue;
}


cheers
Marty
Brian Lam
2010-02-03 22:58:58 UTC
Permalink
Post by Martin Barry
$quoted_author = "Brian Lam" ;
Post by Brian Lam
it looks like it's not looping anymore but it's not updating any of the
f10
Post by Brian Lam
switches (the previous working f10 are not updated either). rancid log
shows
I think it might be because it has a two stage "quit" rather than just
needing a different command.
Post by Brian Lam
maybe i will target the stanza instead and have better luck. the loop
output is below. the first 'exit' works but the 2nd on throws an error
'%
Post by Brian Lam
Invalid input detected at '^' marker.'
Try something like
"Invalid input detected at" { # F10 two stage quit
send -h "quit\r"
exp_continue;
}
works like a charm. thank you so much. my mistake was the i didn't use
'exp_continue'! :p rookie mistake. it's about time to get pick up a book
on Expect.
Post by Martin Barry
cheers
Marty
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
--
Brian Lam | IT/Operations | Rockyou, Inc. | Phone: 408-425-9801 | AIM:
brianclam2
Continue reading on narkive:
Loading...