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?
cheers,
ric
--
World's leading developer of neural notwerks.
·····@cs.ucla.edu
http://www.cs.ucla.edu/~cardo/
PGP Key info: 1024/3D0B0709 FF C9 53 36 E4 3B 51 C9 81 4D 8D 8E FD A6 57 7F
·····@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
·········@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
--
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
···············@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