[rancid] Problem with custom device script

john heasley heas at shrubbery.net
Sat Apr 9 17:59:50 UTC 2011


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.



More information about the Rancid-discuss mailing list