Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel-eecis!gatech!news.mathworks.com!fu-berlin.de!cs.tu-berlin.de!news.uni-hamburg.de!news.Hanse.DE!wavehh.hanse.de!cracauer
From: cracauer@wavehh.hanse.de (Martin Cracauer)
Subject: Re: pipes to processes in CMU Lisp
Message-ID: <1997Mar6.104424.7066@wavehh.hanse.de>
Reply-To: cracauer@wavehh.hanse.de
Organization: '(a (cons tructive organization))
References: <5fl9l4$aqm@delphi.cs.ucla.edu>
Date: Thu, 6 Mar 97 10:44:24 GMT
Lines: 42

cardo@cs.ucla.edu (Ric Crabbe) writes:

>In my project I was doing in gcl, I spawned a C program and
>communicated with it via a text pipe (on Linux).

>I did this with:
>(system (format nil "mkfifo ~a" pipe-name))
>(system (format nil "~a~{ ~a~} < ~a &" prog args pipe-name))
>...
>(setq pipe (open pipe-name))
>(format pipe "text data")

>I'm trying to port this to CMU Lisp.  I know I use run-program:
>(run-program prog args :input ?stream? :wait nil)

>but I don't really understand streams very well.  What is the stream I
>use?  Or is there a better way?

Well, the manual of CMUCL lacks examples for run-program. Maybe you
want to contribute some after you have things working? (mail to
cmucl-imp@cons.org just in case :-)

Here's a function from code/bsd-os.lisp, reading from a pipe:

(defun software-version ()
  "Returns a string describing version of the supporting software."
  (string-trim '(#\newline)
	       (with-output-to-string (stream)
		 (run-program "/usr/bin/uname" '("-sr") :output stream))))

(run-program ...) can be quite tricky in that some non-obvious
synchronisation might be required when doing advanced things. I have
an example of filtering (writing and then reading) using an external
process, let me know if you need it.

Happy Lisping
	Martin
-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Martin_Cracauer@wavehh.hanse.de http://cracauer.cons.org  Fax.: +4940 5228536
"As far as I'm concerned,  if something is so complicated that you can't ex-
 plain it in 10 seconds, then it's probably not worth knowing anyway"- Calvin
