Hi,
I'm curious how you call standalone external programs from cl, and
capture their stdout/stderr. Even something analagous to sytstem(3)
would be fine. I apologize if this is really basic, but I can't find
any information about it. (Might be good for the proposed cl
cookbook?)
Thanks.
············@yahoo.com (Herman Stein) writes:
> I'm curious how you call standalone external programs from cl, and
> capture their stdout/stderr.
The following code snippet from lisp2wish.lisp (with a slight
alteration for CLISP 2.27) shows a few implimentations' ways of doing
it:
(defun OPEN-PROCESS-STREAM (cmd &optional arguments)
#+:CLISP (ext:run-program cmd
:arguments arguments
:input :stream
:output :stream)
#+:LUCID (lcl:run-program cmd
:arguments arguments
:input :stream
:output :stream
:wait NIL)
#+:ALLEGRO (run-shell-command
(format NIL "exec ~A~{ \"~A\"~}" cmd arguments)
:input :stream
:output :stream
:wait NIL)
#+:KCL (run-program cmd arguments))
(The KCL one is defined elsewhere in the code but I won't paste that
in here since it's probably safe to assume that's not what your
using.)
For LispWorks, CMUCL, and SBCL I'm as curious to know as you are.
To see the how the whole thing works I recommend trying out
lisp2wish.lisp and examining the code. It starts up the standalone
program wish and communicates with it exactly as you describe.
<http://ww.telent.net/cliki/Graphics%20Toolkit> -- Lisp2wish.lisp
(If you are using CLISP you will have to change the package of
RUN-PROGRAM to "ext" as I did above, the file on Cliki is out of
date.)
<https://sourceforge.net/projects/clslideshow/> -- a more involved
demonstration of it in action. (Also includes lisp2wish.lisp with
changes already made.)
-JC
(Switch "at" and first period to mail me)
Jonathan Craven <········@craven.mail.mcgill.ca> writes:
> <https://sourceforge.net/projects/clslideshow/> -- a more involved
> demonstration of it in action. (Also includes lisp2wish.lisp with
> changes already made.)
As is <http://quadium.net/code/splash/>. It has a CLOS-based widget
framework which integrates with Tk.
I've been working on a similar but more elaborate version lately,
which is more useful for real applications. Current prototype may be
visible some time soon.
--
vsync
http://quadium.net/
(cons (cons (car (cons 'c 'r)) (cdr (cons 'a 'o))) ; Orjner
(cons (cons (car (cons 'n 'c)) (cdr (cons nil 's))) nil))
"Jonathan Craven" <········@craven.mail.mcgill.ca> wrote in message
···················@mail.mcgill.ca...
> ············@yahoo.com (Herman Stein) writes:
>
> > I'm curious how you call standalone external programs from cl, and
> > capture their stdout/stderr.
>
> The following code snippet from lisp2wish.lisp (with a slight
> alteration for CLISP 2.27) shows a few implimentations' ways of doing
> it:
>
> (defun OPEN-PROCESS-STREAM (cmd &optional arguments)
> #+:CLISP (ext:run-program cmd
> :arguments arguments
> :input :stream
> :output :stream)
> #+:LUCID (lcl:run-program cmd
> :arguments arguments
> :input :stream
> :output :stream
> :wait NIL)
> #+:ALLEGRO (run-shell-command
> (format NIL "exec ~A~{ \"~A\"~}" cmd arguments)
> :input :stream
> :output :stream
> :wait NIL)
> #+:KCL (run-program cmd arguments))
>
> (The KCL one is defined elsewhere in the code but I won't paste that
> in here since it's probably safe to assume that's not what your
> using.)
>
> For LispWorks, CMUCL, and SBCL I'm as curious to know as you are.
#+LispWorks
(sys:open-pipe (format NIL "exec ~A~{ \"~A\"~}" cmd arguments))
though the exec doesn't seem to be needed on Linux at least (I guess that
/bin/sh is smart enough to do it when there is only one command).
Alternatively, if cmd is a full path then
(sys:open-pipe (cons cmd arguments))
will run it directly.
Also, you might want to use sys:call-system or sys:call-system-showing-output in
other cases.
--
Martin Simmons, Xanalys Software Tools
······@xanalys.com
rot13 to reply
············@yahoo.com (Herman Stein) writes:
> I'm curious how you call standalone external programs from cl, and
> capture their stdout/stderr. Even something analagous to sytstem(3)
> would be fine. I apologize if this is really basic, but I can't find
> any information about it. (Might be good for the proposed cl
> cookbook?)
What implementation do you use?
Cheers,
M.
--
I would hereby duly point you at the website for the current pedal
powered submarine world underwater speed record, except I've lost
the URL. -- Callas, cam.misc
From: Brian P Templeton
Subject: Re: calling external programs
Date:
Message-ID: <87d6zkejkk.fsf@tunes.org>
············@yahoo.com (Herman Stein) writes:
> Hi,
>
> I'm curious how you call standalone external programs from cl, and
> capture their stdout/stderr. Even something analagous to sytstem(3)
> would be fine. I apologize if this is really basic, but I can't find
> any information about it. (Might be good for the proposed cl
> cookbook?)
>
SBCL and, IIANM, CMUCL have the RUN-PROGRAM function:
* (run-program "/bin/ls" '() :output t)
#.newsrc-dribble# PRCS dwork semantic.cache tmp-dylan worlds.html
GNUstep arc lib share tunes.mbox www
Mail bin misc src typescript
News doc school tmp world.mmbox
#<SB-IMPL::PROCESS 685 :EXITED>
*
See `(describe 'run-program)'. This is not a standard CL function and
probably isn't available except in SBCL and CMUCL.
> Thanks.
hth,
--
BPT <···@tunes.org> /"\ ASCII Ribbon Campaign
backronym for Linux: \ / No HTML or RTF in mail
Linux Is Not Unix X No MS-Word in mail
Meme plague ;) ---------> / \ Respect Open Standards