[rancid] run_commands adaptation for Huawei
georg.naggies at r-it.at
georg.naggies at r-it.at
Mon Jul 10 11:02:27 UTC 2006
Hello!
I'm trying to adapt Rancid for Huawei routers, by doing a "3comlogin" from
clogin.
Logging in is easy, with minimal adaptation of clogin.
I'm having trouble though to get run_commands to work. I commented out
this line
-re "^\[^\n\r *]*$reprompt" {send_user -- "$expect_out(buffer)"}
otherwise it breaks out of the one loop, just after the commands are sent,
immediately. When I do away with the line, I never get to breaking out of
the loop, though, of course.
Can someone shed light on how clogin distinguishes from a prompt after
commands are done, breaking out of the loop, from a prompt before
commands?
In other words, what's the difference between
"^\[^\n\r]*$reprompt."
and
"^\[^\n\r *]*$reprompt" ?
I have been thinking long on the regular expressions, therefore now trying
my luck on the list,
thanks
Georg Naggies
(Georg Naggies
IT Service Operations - Support
Problem-Management
Raiffeisen Informatik GmbH
A-1020 Wien, Lilienbrunngasse 7-9
T: +43 1/99 3 98 - 9354
F: +43 1/99 3 99 - 1131
M: +43-664-6275053
mailto:georg.naggies at r-it.at
http://raiffeiseninformatik.at)
PS
code in question, clogin line 630 to 653
expect {
# eating backspaces, explanation from the list archives
-re "\b+" { exp_continue }
# presumably, exiting the loop when commands are done
-re "^\[^\n\r *]*$reprompt" { send_user -- "$expect_out(buffer)" }
}
# continuing the loop
-re "^\[^\n\r]*$reprompt." { send_user -- "$expect_out(buffer)"
exp_continue }
# continuing the loop when seeing new line
-re "\[\n\r]+" { send_user -- "$expect_out(buffer)"
exp_continue }
# sending spaces to various "More"-prompts
-re "\[^\r\n]*Press <SPACE> to cont\[^\r\n]*" {
send " "
# bloody ^[[2K after " "
expect {
-re "^\[^\r\n]*\r" {}
}
exp_continue
}
-re "^ *--More--\[^\n\r]*" {
send " "
exp_continue }
-re "^<-+ More -+>\[^\n\r]*" {
send_user -- "$expect_out(buffer)"
send " "
exp_continue }
}
More information about the Rancid-discuss
mailing list