From: James Gamble
Subject: run-program
Date: 
Message-ID: <2u7o8r$g8c@netnews.upenn.edu>
Can anyone give me some information on the use of run-program
in Lucid Lisp?  The Steele textbook does not even mention it.
I am interested in the meaning of the key word parameters in
the call, as well as what the call returns.  I am trying to use
it to run Unix shell commands.
From: Barry Margolin
Subject: Re: run-program
Date: 
Message-ID: <2uankeINN9gn@early-bird.think.com>
In article <··········@netnews.upenn.edu> ······@gradient.cis.upenn.edu (James Gamble) writes:
>Can anyone give me some information on the use of run-program
>in Lucid Lisp?  The Steele textbook does not even mention it.

It's not mentioned in the Steele book because it's not part of Common Lisp,
it's a Lucid extension.  It's documented in the Advanced User's Guide
section of the Lucid manual.

The first argument is the pathname of the program to run.  If it's not an
absolute pathname your PATH will be searched.

The :INPUT, :OUTPUT, and :ERROR-OUTPUT arguments can be NIL, a filename,
:STREAM, or a stream created by OPEN, MAKE-LISP-STREAM, or another call to
RUN-PROGRAM.  These specify how the standard input, standard output, and
error output of the program will be redirected.  If it's NIL, it's not
redirected.  If it's a filename, it's connected to that file (like the
shell's < and > redirection).  If it's :STREAM, a pipe is created and a
Lisp stream is connected to it and returned as the value from RUN-PROGRAM
(the input/output stream is returned as the first value, the error stream
as the second); you can then supply input to the program or read its output
by writing to or reading from the returned stream.  If it's a stream, the
program inherits that stream as its input, output, or error output; you can
no longer read or write to it from Lisp.  The defaults are all NIL.

:IF-INPUT-DOES-NOT-EXIST specifies what happens if :INPUT is given a
filename and the file doesn't exist.  :ERROR, the default, signals an
error.  :CREATE creates an empty file.  NIL causes RUN-PROGRAM to return
NIL immediately.

:IF-OUTPUT-EXISTS and :IF-ERROR-OUTPUT-EXISTS specify what happens if
:OUTPUT or :ERROR-OUTPUT is given a filename and it already exists.
:ERROR, the default, signals an error.  :APPEND appends to the file.
:OVERWRITE and :SUPERSEDE replace the file.  NIL returns immediately.

:WAIT specifies whether Lisp should wait for the program to exit before
returning from RUN-PROGRAM.  You have to use :WAIT NIL if any of :INPUT,
:OUTPUT, or :ERROR-OUTPUT are :STREAM.  The default is T.

:ARGUMENTS is a list of strings that are passed as arguments to the
program.

The values are:

1. A stream connected to the input and/or output of the
program if either :INPUT or :OUTPUT is :STREAM, otherwise NIL.

2. A stream connected to the error output of the program if :ERROR-OUTPUT
is :STREAM, otherwise NIL.

3. The exit status of the program if :WAIT T is specified, otherwise NIL.

4. The process ID if :WAIT NIL is specified, otherwise NIL.
-- 
Barry Margolin
System Manager, Thinking Machines Corp.

······@think.com          {uunet,harvard}!think!barmar