home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / tcl / 1244 < prev    next >
Encoding:
Internet Message Format  |  1992-08-22  |  2.2 KB

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