<br><br><div class="gmail_quote">On Sat, Apr 9, 2011 at 11:59 AM, john heasley <span dir="ltr"><<a href="mailto:heas@shrubbery.net">heas@shrubbery.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Fri, Apr 08, 2011 at 02:25:07PM -0600, Brian Talley:<br>
<div><div></div><div class="h5">> I'm creating a custom login script for a Crescendo load balancer device. I<br>
> can log in to the device and get to interactive mode ok using the script,<br>
> but when I try to run commands with something like:<br>
><br>
> crescendologin -d -t 30 -c"show running" host<br>
><br>
> it appears that expect is trying to match on every character with output<br>
> like:<br>
><br>
> ...<br>
> send: sending "show running\r" to { exp6 }<br>
><br>
> expect: does "" (spawn_id exp6) match regular expression "^[^\n\r]*root> "?<br>
> no<br>
> "^[^\n\r ]*>>.*root> "? no<br>
> "[\n\r]+"? no<br>
><br>
> expect: does "s" (spawn_id exp6) match regular expression "^[^\n\r]*root> "?<br>
> no<br>
> "^[^\n\r ]*>>.*root> "? no<br>
> "[\n\r]+"? no<br>
> expect: timed out<br>
><br>
> Error: TIMEOUT reached<br>
><br>
> I feel like I'm missing something obvious. The pertinent section of<br>
> run_commands looks like:<br>
><br>
> for {set i 0} {$i < $num_commands} { incr i} {<br>
> send -- "[subst -nocommands [lindex $commands $i]]\r"<br>
> expect {<br>
> -re "^\[^\n\r]*$reprompt" { exp_continue }<br>
> -re "^\[^\n\r *]*$reprompt" {}<br>
> -re "\[\n\r]" { exp_continue }<br>
> }<br>
> }<br>
><br>
> And the actual prompt is "root> "<br>
<br>
</div></div>try ktrace (or truss or strace) on the process. it could be that the<br>
device is slow, the expect (tcl) is reading one char at a time, the<br>
tty is in a weird mode; as just a few guesses.<br>
<br>
it is not uncommon for single chars to be read sometimes. the key is<br>
create matches that dont consume the single chars; cause it to read<br>
more and concatenate the input into complete lines.<br>
<br>
</blockquote></div><div><br></div>After some trial and error I was able to get this to work by using<div><span class="Apple-style-span" style="font-family: 'Times New Roman'; font-size: medium; "><pre>set send_human {.1 .3 1 .05 2}</pre>
</span>
<div>Thanks,</div></div><div>Brian</div>