expect: kick off a task with lots of output, but don't process output after that 
Author Message
 expect: kick off a task with lots of output, but don't process output after that

<code to kick off long job>
set timeout -1   <megabytes of screen output to follow>
expect eof
exit

<where all output is to be logged:>
script.exp > log

to save CPU cycles, I would like expect not to compare each returning string
for an eof.  Ideally, it should just kick the process to the background at
this stage, and exit, leaving the output to go to the log file.
Unfortunately, even with the aid of "Exploring Expect" I haven't been able
to do this.  Using fork and wait alone will not work.

Suggestions appreciated.

Rob



Fri, 11 Jul 2003 20:45:15 GMT  
 expect: kick off a task with lots of output, but don't process output after that

Quote:

> <code to kick off long job>
> set timeout -1   <megabytes of screen output to follow>
> expect eof
> exit

> <where all output is to be logged:>
> script.exp > log

> to save CPU cycles, I would like expect not to compare each returning string
> for an eof.

Expect doesn't use string comparison to detect eof.  The test for eof
is trivial (a single machine instruction) and is a fraction of the
time spent actually transferring characters, so you're worrying
needlessly.

Quote:
> .......  Ideally, it should just kick the process to the background at
> this stage, and exit, leaving the output to go to the log file.
> Unfortunately, even with the aid of "Exploring Expect" I haven't been able
> to do this.  Using fork and wait alone will not work.

Since you have the book, just read the "Background" chapter.  It
explains how Expect scripts can put themselves in the background.

Don



Fri, 11 Jul 2003 23:38:54 GMT  
 expect: kick off a task with lots of output, but don't process output after that
Thanks for the reply, Don, I feel honoured and embarrassed at the attention.

Yes, I initially moved my expect statement from a nonsense string to "eof"
and did indeed get reduced CPU utilisation.  But not enough: the Expect
process sometimes still uses as much as 25% of a CPU (whilst the application
might claim 98% of another CPU) which I would like to reclaim as I sometimes
have tens of these processes running simultaneously.

Naturally, I have read the Background chapter, and am frequently aware that
a significant proportion of my brain isn't working so I still haven't
figured how to allow the expect process to end completely (not just continue
in the background) but let the application continue and preserve my output
in its log file.  I need something like the disconnect command, but not
something which disconnects the expect script from the controlling terminal
but rather disconnects the application from the expect script, I think.

rdgs
rob


Quote:

> > <code to kick off long job>
> > set timeout -1   <megabytes of screen output to follow>
> > expect eof
> > exit

> > <where all output is to be logged:>
> > script.exp > log

> > to save CPU cycles, I would like expect not to compare each returning
string
> > for an eof.

> Expect doesn't use string comparison to detect eof.  The test for eof
> is trivial (a single machine instruction) and is a fraction of the
> time spent actually transferring characters, so you're worrying
> needlessly.

> > .......  Ideally, it should just kick the process to the background at
> > this stage, and exit, leaving the output to go to the log file.
> > Unfortunately, even with the aid of "Exploring Expect" I haven't been
able
> > to do this.  Using fork and wait alone will not work.

> Since you have the book, just read the "Background" chapter.  It
> explains how Expect scripts can put themselves in the background.

> Don



Sat, 12 Jul 2003 17:32:47 GMT  
 expect: kick off a task with lots of output, but don't process output after that

Quote:

> Thanks for the reply, Don, I feel honoured and embarrassed at the attention.

> Yes, I initially moved my expect statement from a nonsense string to "eof"
> and did indeed get reduced CPU utilisation.  But not enough: the Expect
> process sometimes still uses as much as 25% of a CPU (whilst the application
> might claim 98% of another CPU) which I would like to reclaim as I sometimes
> have tens of these processes running simultaneously.

I just did an experiment: I spawned a process that generates
characters as fast as it can; expect uses 1% of my (slow) desktop's
CPU.  Can't imagine why you're seeing 25%.  Expect doesn't need to do
very much work to handle "expect eof".  (Most of the time should be
spent waiting in Tcl's event loop.)

Quote:
> Naturally, I have read the Background chapter, and am frequently aware that
> a significant proportion of my brain isn't working so I still haven't
> figured how to allow the expect process to end completely (not just continue
> in the background) but let the application continue and preserve my output
> in its log file.  I need something like the disconnect command, but not
> something which disconnects the expect script from the controlling terminal
> but rather disconnects the application from the expect script, I think.

Oh, now I see what you mean.  No, you can't do that.  There's no
payoff anyway - assuming you can figure out what's going on with that
anomolous 25%.

Don

Quote:

> rdgs
> rob




> > > <code to kick off long job>
> > > set timeout -1   <megabytes of screen output to follow>
> > > expect eof
> > > exit

> > > <where all output is to be logged:>
> > > script.exp > log

> > > to save CPU cycles, I would like expect not to compare each returning
> string
> > > for an eof.

> > Expect doesn't use string comparison to detect eof.  The test for eof
> > is trivial (a single machine instruction) and is a fraction of the
> > time spent actually transferring characters, so you're worrying
> > needlessly.

> > > .......  Ideally, it should just kick the process to the background at
> > > this stage, and exit, leaving the output to go to the log file.
> > > Unfortunately, even with the aid of "Exploring Expect" I haven't been
> able
> > > to do this.  Using fork and wait alone will not work.

> > Since you have the book, just read the "Background" chapter.  It
> > explains how Expect scripts can put themselves in the background.

> > Don



Sun, 13 Jul 2003 01:02:29 GMT  
 expect: kick off a task with lots of output, but don't process output after that

Quote:
> > Yes, I initially moved my expect statement from a nonsense string to
"eof"
> > and did indeed get reduced CPU utilisation.  But not enough: the Expect
> > process sometimes still uses as much as 25% of a CPU (whilst the
application
> > might claim 98% of another CPU) which I would like to reclaim as I
sometimes
> > have tens of these processes running simultaneously.

> I just did an experiment: I spawned a process that generates
> characters as fast as it can; expect uses 1% of my (slow) desktop's
> CPU.  Can't imagine why you're seeing 25%.  Expect doesn't need to do
> very much work to handle "expect eof".  (Most of the time should be
> spent waiting in Tcl's event loop.)

I've just run another test:  must be an architecture/OS thing.  Running on a
multi-proc Sun the Expect process uses insignificant amounts of CPU, but
running on DYNIX/ptx (Sequent) the expect process uses from 2 - 25% of a
processor.  I'm using the most recent versions of TCL for both.

Quote:

> > Naturally, I have read the Background chapter, and am frequently aware
that
> > a significant proportion of my brain isn't working so I still haven't
> > figured how to allow the expect process to end completely (not just
continue
> > in the background) but let the application continue and preserve my
output
> > in its log file.  I need something like the disconnect command, but not
> > something which disconnects the expect script from the controlling
terminal
> > but rather disconnects the application from the expect script, I think.

> Oh, now I see what you mean.  No, you can't do that.  There's no
> payoff anyway - assuming you can figure out what's going on with that
> anomolous 25%.

at least I know I'm basically on the right track.  Thanks for the feedback.

- Show quoted text -

Quote:



> > > > <code to kick off long job>
> > > > set timeout -1   <megabytes of screen output to follow>
> > > > expect eof
> > > > exit

> > > > <where all output is to be logged:>
> > > > script.exp > log

> > > > to save CPU cycles, I would like expect not to compare each
returning
> > string
> > > > for an eof.

> > > Expect doesn't use string comparison to detect eof.  The test for eof
> > > is trivial (a single machine instruction) and is a fraction of the
> > > time spent actually transferring characters, so you're worrying
> > > needlessly.

> > > > .......  Ideally, it should just kick the process to the background
at
> > > > this stage, and exit, leaving the output to go to the log file.
> > > > Unfortunately, even with the aid of "Exploring Expect" I haven't
been
> > able
> > > > to do this.  Using fork and wait alone will not work.

> > > Since you have the book, just read the "Background" chapter.  It
> > > explains how Expect scripts can put themselves in the background.

> > > Don



Sun, 13 Jul 2003 16:22:12 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Expect timeout and background process' output

2. Tear-off menus don't respect vertical task bar

3. Expecting output from a background process

4. Expect: Preventing output from spawned processes

5. expect script not getting output from spawned process

6. expect: suppress spwan process output

7. Want input and output of process, but simpler than expect

8. Don't want 0x1A character at and of outputted text files

9. Don't know how to specify a digital input or output with Port Config

10. How to disable spawnv's child process output messages

11. Expect'ing large amounts of output, versus performance measuring

12. expect: redirect output into file called `uname -n'.txt

 

 
Powered by phpBB® Forum Software