home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / c / 18981 < prev    next >
Encoding:
Text File  |  1992-12-29  |  1.6 KB  |  44 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!agate!linus!linus.mitre.org!elara.mitre.org!bdickens
  3. From: bdickens@elara.mitre.org (Brian Dickens)
  4. Subject: UNIX pipes in C
  5. Message-ID: <1992Dec29.183248.8309@linus.mitre.org>
  6. Keywords: UNIX, pipes, C
  7. Sender: news@linus.mitre.org (News Service)
  8. Nntp-Posting-Host: elara.mitre.org
  9. Organization: Research Computer Facility, MITRE Corporation, Bedford, MA
  10. Date: Tue, 29 Dec 1992 18:32:48 GMT
  11. Lines: 31
  12.  
  13. I am attempting to write a program that will control another program -- by
  14. means of pipes.  For example, suppose I have one program that does math
  15. calculations, called calc.  A sample interaction with calc might look like this:
  16.  
  17. % calc
  18. CALC PROGRAM... Please enter your problem: 3+5
  19. 8
  20. CALC PROGRAM... Please enter your problem: 8*8
  21. 64
  22. CALC PROGRAM... Please enter your problem: quit
  23. Thank you for using CALC PROGRAM.
  24. %
  25.  
  26. Another program wishes to perform calculations with calc.  For example,
  27. this program could be called frontend.  Frontend would look something
  28. like this:
  29.  
  30. % frontend
  31. FRONT END TO THE CALCULATOR... Please enter your expresssion: 2+7
  32. RESPONSE FROM THE CALCULATOR is 9.  Thank you for using frontend!
  33. %
  34.  
  35. The program which corresponds to the "calc" program above has already
  36. been written.  I need to know what kind of code I have to write to set up a
  37. link between my program (analogous to "frontend") and the "calc" program.
  38. The manpages for fork() and pipe() are very confusing for me, and I don't
  39. see how to do this.
  40.  
  41. Any help would be appreciated... Thanks!
  42. <<<?>>> bdickens@elara.mitre.org <<<!>>>
  43.  
  44.