Discussion:
[rancid] clogin doesn't send explicitly set new lines
Aliaksei Sheshka
2013-05-15 19:38:13 UTC
Permalink
Hi!

I'm facing rather strange clogin issue.
Consider file :
----begin nyy-r14-confg.sample file ---
sh clock
copy system:/running-config tftp://10.18.15.11/nyy-r14-confg




sh clock
----end nyy-r14-confg.sample file ---
There are four lines with '\n' only.
My idea was that:
cisco says -> Address or name of remote host [10.18.15.11]?
clogin sends -> '\n'
cisco says -> Destination filename [nyy-r14-confg]?
clogin sends -> '\n'
And then two times '\n' just for test.
Nope, clogin just stuck. Debug message for "$clogin -d -t 3600 -x
nyy-r14-confg.sample nyy-r14" :

expect: does "Address or name of remote host [10.18.15.11]? "
(spawn_id exp6) match regular expression "\u0008+"? (No Gate, RE only)
gate=yes re=no
"^[^\n\r *]*nyy-r14([^#>\r\n]+)?[#>](\([^)\r\n]+\))?"? Gate "*nyy-r14*"? gate=no
"^[^\n\r]*nyy-r14([^#>\r\n]+)?[#>](\([^)\r\n]+\))?."? Gate "*nyy-r14*"? gate=no
"^--More--[\r\n]+"? Gate "--More--*"? gate=no
"[^\r\n]*[\n\r]+"? (No Gate, RE only) gate=yes re=no
"[^\r\n]*Press <SPACE> to cont[^\r\n]*"? Gate "*Press <SPACE> to cont*"? gate=no
"^ *--More--[^\n\r]*"? Gate "*--More--*"? gate=no
"^<-+ More -+>[^\n\r]*"? (No Gate, RE only) gate=yes re=no

And then nothing, timeout.
System is Debian wheezy
expect 5.44.1.15-4
rancid 2.3.8-3

I added some lines:
$diff /usr/lib/rancid/bin/clogin.orig /usr/lib/rancid/bin/clogin
707a708,715
-re "Destination filename" {
send_user -- "$expect_out(buffer)"
send "\n"
exp_continue }
-re "Address or name of remote host" {
send_user -- "$expect_out(buffer)"
send "\n"
exp_continue }
and that suddenly fixed the issue.

That puzzled me, because I had a FreeBSD system with expect 5.44 and
rancid 2.3.6 and the same nyy-r14-confg.sample was processed without
any issues.
What could be wrong ?
heasley
2013-05-16 15:22:09 UTC
Permalink
Post by Aliaksei Sheshka
Hi!
I'm facing rather strange clogin issue.
----begin nyy-r14-confg.sample file ---
sh clock
copy system:/running-config tftp://10.18.15.11/nyy-r14-confg
sh clock
----end nyy-r14-confg.sample file ---
There are four lines with '\n' only.
cisco says -> Address or name of remote host [10.18.15.11]?
clogin sends -> '\n'
cisco says -> Destination filename [nyy-r14-confg]?
clogin sends -> '\n'
And then two times '\n' just for test.
Nope, clogin just stuck. Debug message for "$clogin -d -t 3600 -x
expect: does "Address or name of remote host [10.18.15.11]? "
(spawn_id exp6) match regular expression "\u0008+"? (No Gate, RE only)
gate=yes re=no
"^[^\n\r *]*nyy-r14([^#>\r\n]+)?[#>](\([^)\r\n]+\))?"? Gate "*nyy-r14*"? gate=no
"^[^\n\r]*nyy-r14([^#>\r\n]+)?[#>](\([^)\r\n]+\))?."? Gate "*nyy-r14*"? gate=no
"^--More--[\r\n]+"? Gate "--More--*"? gate=no
"[^\r\n]*[\n\r]+"? (No Gate, RE only) gate=yes re=no
"[^\r\n]*Press <SPACE> to cont[^\r\n]*"? Gate "*Press <SPACE> to cont*"? gate=no
"^ *--More--[^\n\r]*"? Gate "*--More--*"? gate=no
"^<-+ More -+>[^\n\r]*"? (No Gate, RE only) gate=yes re=no
its looking for stuff that matches the prompt regex it has concocted:
^[^\n\r]*nyy-r14([^#>\r\n]+)?[#>](\([^)\r\n]+\))?.

if you want to embed commands in commands with alternate prompting, they
must be embedded on one line:
show clock
copy blah blah\n\n
show clock

or use the -s option instead and see rancid/share/*.exp.
Post by Aliaksei Sheshka
And then nothing, timeout.
System is Debian wheezy
expect 5.44.1.15-4
rancid 2.3.8-3
$diff /usr/lib/rancid/bin/clogin.orig /usr/lib/rancid/bin/clogin
707a708,715
-re "Destination filename" {
send_user -- "$expect_out(buffer)"
send "\n"
exp_continue }
-re "Address or name of remote host" {
send_user -- "$expect_out(buffer)"
send "\n"
exp_continue }
and that suddenly fixed the issue.
That puzzled me, because I had a FreeBSD system with expect 5.44 and
rancid 2.3.6 and the same nyy-r14-confg.sample was processed without
any issues.
What could be wrong ?
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
Aliaksei Sheshka
2013-05-16 17:26:23 UTC
Permalink
Post by Aliaksei Sheshka
^[^\n\r]*nyy-r14([^#>\r\n]+)?[#>](\([^)\r\n]+\))?.
if you want to embed commands in commands with alternate prompting, they
show clock
copy blah blah\n\n
show clock
or use the -s option instead and see rancid/share/*.exp.
Thank you for explanation!

As as side question, I'm using clogin for force10 routers as well and see:
router1#terminal width 132^M
^^M
% Error: Invalid input at "^" marker
it's safe to ignore, only extra lines in logs.
As much as I understand there is no separate f10login ? (not needed I
guess, mostly cisco style cmd there)

Loading...