
4.2 Running UNIX programs from Lisp
run-program. The:input,:output, and:error-output keyword options determine the standard input stream, standard output stream, and error output stream of the program respectively.:inputnil:input isnil, the standard input stream for the program is the standard input stream for Lisp, which is normally the terminal. This option is analogous to typing a simple command to the Shell with no input redirection. The default value for:input isnil.
:input is a filename, the standard input stream for the program is a stream opened to the specified file. This option is analogous to using the input redirection symbol < with a Shell command. If the file does not exist, the value of the argument:if-input-does-not-exist determines the outcome, as follows::error, an error is signaled.:create, an empty file to read from is created and is given the specified filename.nil,run-program returnsnil without taking any action.:stream:input is:stream, the standard input stream for the program is a newly created Lisp output stream that is returned as the first value ofrun-program. Anything written to that stream by Lisp is read by the program. When the stream is closed, the program reads an end-of-file indicator. If for some reason the program terminates, writing to that stream causes Lisp to signal an error.
:input is a stream, the standard input stream for the program is that stream, which must be an input stream open to a file or to another process. The stream must not be a string stream, synonym stream, or another higher-level Lisp stream.
open, the function make-lisp-stream, or the functionrun-program. (Note that the Common Lisp macro with-open-file does an implicitopen; that is, ifwith-open-file is called, a stream is created.)
run-program with the:output argument set to the value:stream. Then callrun-program again and use the newly created stream as the:input argument.
:outputnil:output isnil, the standard output stream of the program is the standard output stream of Lisp, which is normally the terminal. This option is analogous to typing a simple command to the Shell and specifying no output redirection. The default value for :output isnil.
:output is a filename, the standard output stream of the program is a stream opened to the specified file. This option is analogous to using the output redirection symbols> and>> with a Shell command. If the file already exists, the value of the:if-output-exists argument determines the outcome, as follows::error or is omitted, an error is signaled.:append, the standard output stream from the program is appended to the end of the file.:overwrite or:supersede, the file is overwritten by the standard output stream from the program.nil,run-program returnsnil without taking any other action.:stream:output is:stream, the standard output stream of the program is a newly created Lisp input stream that is returned as the first value ofrun-program. Lisp can read from this stream to get the program's standard output stream.
:output is an output stream, the standard output stream of the program is that stream. The same restrictions that apply to a stream specified as:input apply to one specified as:output. Once a Lisp stream is passed to a program, the stream can no longer be written to or read from by Lisp. It is effectively closed.
:error-output:output keyword argument, with the following exceptions::output. If the value of:error-output is:output, error output is merged with the program's standard output stream.:if-error-output-exists argument, rather than by the value of the:if-output-exists argument.:wait:wait ist, Lisp does not begin running until the program has completed; this value is the default.:wait isnil, Lisp continues to run in parallel with the program.:wait ist and the value of:input,:output, or:error-output is:stream, an error is signaled. Waiting and having a stream open to a process can lead to deadlock; thus, these combinations are not permitted.:arguments
:if-input-does-not-exist,:if-output-exists, and:if-error-output-exists keyword arguments are significant only if the value of:input,:output, or:error-output is a filename. The default value of each of the three arguments is:error.:if-input-does-not-exist:error signals an error; this value is the default.:create creates an empty file.nil returnsnil without doing anything if the file mentioned does not exist.:if-output-exists,:if-error-output-exists:error signals an error; this value is the default.:append appends output to the file.:overwrite and:supersede overwrite the file with the new output.nil returnsnil without doing anything if the file mentioned already exists.:supersede is supported for the purposes of backward compatibility.

Generated with Harlequin WebMaker