[rancid] Problem with custom device script
Brian Talley
b225ccc at gmail.com
Sun Apr 10 20:46:20 UTC 2011
On Sat, Apr 9, 2011 at 11:59 AM, john heasley <heas at shrubbery.net> wrote:
> Fri, Apr 08, 2011 at 02:25:07PM -0600, Brian Talley:
> > I'm creating a custom login script for a Crescendo load balancer device.
> I
> > can log in to the device and get to interactive mode ok using the script,
> > but when I try to run commands with something like:
> >
> > crescendologin -d -t 30 -c"show running" host
> >
> > it appears that expect is trying to match on every character with output
> > like:
> >
> > ...
> > send: sending "show running\r" to { exp6 }
> >
> > expect: does "" (spawn_id exp6) match regular expression "^[^\n\r]*root>
> "?
> > no
> > "^[^\n\r ]*>>.*root> "? no
> > "[\n\r]+"? no
> >
> > expect: does "s" (spawn_id exp6) match regular expression "^[^\n\r]*root>
> "?
> > no
> > "^[^\n\r ]*>>.*root> "? no
> > "[\n\r]+"? no
> > expect: timed out
> >
> > Error: TIMEOUT reached
> >
> > I feel like I'm missing something obvious. The pertinent section of
> > run_commands looks like:
> >
> > for {set i 0} {$i < $num_commands} { incr i} {
> > send -- "[subst -nocommands [lindex $commands $i]]\r"
> > expect {
> > -re "^\[^\n\r]*$reprompt" { exp_continue }
> > -re "^\[^\n\r *]*$reprompt" {}
> > -re "\[\n\r]" { exp_continue }
> > }
> > }
> >
> > And the actual prompt is "root> "
>
> try ktrace (or truss or strace) on the process. it could be that the
> device is slow, the expect (tcl) is reading one char at a time, the
> tty is in a weird mode; as just a few guesses.
>
> it is not uncommon for single chars to be read sometimes. the key is
> create matches that dont consume the single chars; cause it to read
> more and concatenate the input into complete lines.
>
>
After some trial and error I was able to get this to work by using
set send_human {.1 .3 1 .05 2}
Thanks,
Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.shrubbery.net/pipermail/rancid-discuss/attachments/20110410/0d7a6640/attachment.html>
More information about the Rancid-discuss
mailing list