home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / prolog / 1625 < prev    next >
Encoding:
Text File  |  1992-08-30  |  2.7 KB  |  59 lines

  1. Newsgroups: comp.lang.prolog
  2. Path: sparky!uunet!munnari.oz.au!hp9000.csc.cuhk.hk!cucs5.cs.cuhk.hk!bmtong
  3. From: bmtong@cucs11.cs.cuhk.hk (Tong Bo-Ming)
  4. Subject: Re: Pipes in Quintus
  5. Message-ID: <1992Aug30.090317.4088@cucs5.cs.cuhk.hk>
  6. Sender: news@cucs5.cs.cuhk.hk
  7. Organization: Faculty of Engineering, The Chinese U. of Hong Kong
  8. References: <17ljnjINNlbo@swan.doc.ic.ac.uk>
  9. Date: Sun, 30 Aug 1992 09:03:17 GMT
  10. Lines: 47
  11.  
  12. jvp@doc.ic.ac.uk (Jeremy Pitt) writes:
  13.  
  14. >I've got this Quintus prolog program and this C program and, quite
  15. >unreasonably really, I want them to `talk' to each other.
  16.  
  17. >However, the Quintus library predicate popen only allows me to get
  18. >hold of one end of the pipe: I can either read from it or write
  19. >to it, but not both.
  20.  
  21. >Does anybody either (a) know of an easy way of doing both or (b) have
  22. >a library package which exports predicates to do this.
  23.  
  24. >Oh, and on top of that the C program writes its output to standard
  25. >error (don't ask). So what I want is to be able to send stuff from
  26. >my Quintus program through the pipe to the C program, and pick up 
  27. >its output off standard error when its finished munging about with
  28. >it.
  29.  
  30. >Don't want much, do I? However, any help with this would be greatly
  31. >appreciated. Thanks,
  32.  
  33. >Jeremy
  34. >--
  35. >Jeremy Pitt, Department of Computing, Imperial College of Science, Technology
  36. >& Medicine, Huxley Building, 180, Queen's Gate, London, England, SW7 2BZ.
  37. >jvp@doc.ic.ac.uk    +44 71 589 5111 ext 4983
  38.  
  39.     I think it would be worth trying to create two named pipe files
  40. (if you're using System V) in the /tmp directory, one for Quintus -> C
  41. and the other for C -> Quintus.  You can redirect stderr and stdin of the
  42. C program to these pipes.  Try using open/3 to open these pipe files in
  43. Quintus (not quite sure whether this works).  If this does not work, try
  44. redirecting Quintus' input and output streams to these files.  (tell/1,
  45. told/0, etc).  If all these fails, write a small C program for opening
  46. pipe files and link it to Quintus.
  47.  
  48.     Some time ago, I tried these techniques, but now I have already
  49. forgotten how I let Quintus and C talk to each other exactly.  Of course,
  50. the solution depends on the particular situation.  If this is not detailed
  51. enough, you may send a email to me so that I will try these things out
  52. myself to give you a more complete answer.
  53.  ________________________________________________________________
  54. | Was entstanden ist, das muB vergehen !                         |
  55. | Was vergangen, auferstehen !                                   |
  56. |                          Mahler: Symphony No. 2 "resurrection" |
  57. |________________________________________________________________|
  58. Tong Bo-Ming                              email: bmtong@cs.cuhk.hk
  59.