Home > Archive > Tcl > March 2004 > Expect doesn't know when to quit
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Expect doesn't know when to quit
|
|
| Marlin Mixon 2004-03-29, 10:37 pm |
| I've got this expect script working pretty well (See excerpts below)
(Thanks Don!) except that when I run it, it doesn't know when to
terminate and doesn't flush the last bit of buffer so the info I'm
trying to capture is always incomplete.
What I observe:
The log in works OK and I can see expect negotiating the session fine.
It invokes the script and a bunch of text (data records) starts
flying by (about one MB)
At the end, I see this: It looks fine to me--looks like expect is
doing what it's supposed to:
Are you sure you want to log off the system [NO]? YES
Connection closed by foreign host.R-2004 20:11:54.13
$
The problem here is when I press return at the prompt, nothing
happens. I press return again and I get four beeps and:
$ 6c6c6c6c6c
bash: 6c6c6c6c6c: command not found
$
Code Snippets:
expect "Press <Return> to continue, or press <F7><Q> to quit: "
send -- "\r"
log_file -noappend "output.txt"
expect "xyzzy"
log_file
send -- "^[\[18~Q"
expect "Select Activity:"
<snipped several expect/sends--basically logs out of menu driven
system>
expect "log off the system"
send -- "YES\r"
expect eof
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Any ideas?
Thanks!
Marlin
| |
| Don Libes 2004-03-31, 4:35 pm |
| marlin_mixon@hotmail.com (Marlin Mixon) writes:
> I've got this expect script working pretty well (See excerpts below)
> (Thanks Don!) except that when I run it, it doesn't know when to
> terminate and doesn't flush the last bit of buffer so the info I'm
> trying to capture is always incomplete.
>
> What I observe:
> The log in works OK and I can see expect negotiating the session fine.
> It invokes the script and a bunch of text (data records) starts
> flying by (about one MB)
>
> At the end, I see this: It looks fine to me--looks like expect is
> doing what it's supposed to:
> Are you sure you want to log off the system [NO]? YES
> Connection closed by foreign host.R-2004 20:11:54.13
> $
>
> The problem here is when I press return at the prompt, nothing
> happens. I press return again and I get four beeps and:
>
> $ 6c6c6c6c6c
> bash: 6c6c6c6c6c: command not found
> $
>
> Code Snippets:
> expect "Press <Return> to continue, or press <F7><Q> to quit: "
> send -- "\r"
> log_file -noappend "output.txt"
> expect "xyzzy"
> log_file
> send -- "^[\[18~Q"
> expect "Select Activity:"
>
> <snipped several expect/sends--basically logs out of menu driven
> system>
>
> expect "log off the system"
> send -- "YES\r"
> expect eof
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Any ideas?
>
> Thanks!
>
> Marlin
My bet is that the remote system is sending back some ASCII screen
manipulations that put your terminal emulator into a funky state.
Turn on logging (or diagnostics) so you can figure out what they are.
Once you know what they are, you can tell Expect not to send them on.
Don
|
|
|
|
|