home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dove!cme!libes
- From: libes@cme.nist.gov (Don Libes)
- Newsgroups: comp.lang.tcl
- Subject: Re: How to expect.
- Message-ID: <18947@muffin.cme.nist.gov>
- Date: 22 Aug 92 18:57:44 GMT
- References: <1992Aug21.164145.11775@cc.gatech.edu>
- Organization: National Institute of Standards and Technology
- Lines: 43
-
- In article <1992Aug21.164145.11775@cc.gatech.edu> clayton@cloudgen1.gatech.edu (R. Clayton) writes:
- >I have a program that presents text a screen at at time. I have an expect
- >front-end to the program that issues a sequence of page commands, picks apart
- >the screens and prints the resulting text with send_user. I'd like to run the
- >text through a pager (e.g., more) so the user can control the spew of text, but
- >am unsure how to go about it.
- >
- >One thing I could do is write the text to a file, spawn a pager on the file,
- >and then let the user interact with the pager. This is the effect I want, but
- >I don't want to have the user sitting around waiting while the script writes
- >400+ pages to a file. Another possibility is to fork with the file writer in
- >one copy and the pager in the other, but this raises coordination problems
- >(e.g., when the user pages to the current end-of-file before the writer
- >finished writing the file) in addition to the fact that I haven't been able to
- >get sample scripts written in this style to work. A third possibility is to
- >make a pipeline with the pager and multiplex between the two tasks in the
- >script itself, but I haven't been able to come up with a multiplexing scheme
- >that doesn't involve re-implementing the pager in the script.
- >
- >Any ideas?
-
- Do this:
-
- exec "mknod fifo p" ;# make a fifo
- spawn pager fifo ;# run your pager on the fifo output
-
- Loop waiting for output from 1) your program, 2) pager, and 3) user,
- such that output from:
-
- user goes to pager
- pager goes to user
- your program goes to fifo
-
- If your control of your program is simple enough, you can just fork
- the last part off, and call "interact" and let it handle the first two
- parts of the loop.
-
- Look in kibitz for an example of how to wait on output from three
- different sources.
-
- Feel free to mail further questions directly to me.
-
- Don Libes libes@cme.nist.gov ...!uunet!cme-durer!libes
-