A string, or a list of strings, or
nil
.
:input
,
:output
or
:io
.
A type specifier.
A boolean. Not implemented on Windows.
A shell type.
On Unix/Linux/Mac OS the behaviour of
open-pipe
is analogous to that of
popen
in the UNIX library. It creates a pipe to/from a subprocess and returns a stream. The stream can be read from or written to as appropriate.
On Windows
open-pipe
calls
CreateProcess
and
CreatePipe
and returns a bidirectional stream.
If
command
is a string then it is passed to the shell as the command to run. If
command
is a list, then the first element is the command to run directly and the other elements are passed as arguments on the command line. If
command
is
nil
, then the shell is run.
direction
is a keyword for the stream direction. The default value is
:input
. Bidirectional (i/o) pipes may be created by pasing
:io
. See the example below. This argument is ignored on Windows.
element-type
specifies the type of the stream as with
open
. The default value is
base-char
. This argument is ignored on Windows.
interrupt-off
, if
t
, ensures that Ctrl+C (SIGINT) to the LispWorks image is ignored by the subprocess. This argument is not implemented on Windows.
shell-type
specifies the type of shell to run. On UNIX/Linux/Mac OS the default value is
"/bin/sh"
. On Windows the default value is
"cmd"
. Note that on Windows ME/98/95 you will need to pass
"command"
.
stream supports mixed character and binary I/O in the same way as file streams constructed by open.
CL-USER 1 > (setf *ls* (sys:open-pipe "ls"))
Warning: Setting unbound variable *LS*
#<SYSTEM::PIPE-STREAM "ls">
CL-USER 2 > (loop while
(print (read-line *ls* nil nil)))
"hello"
"othello"
NIL
NIL
CL-USER 3 > (close *ls*)
T
The following example shows you how to use bidirectional pipes.
CL-USER 1 > (with-open-stream
(s (sys:open-pipe "/bin/csh"
:direction :io))
(write-line "whereis ls" s)
(force-output s)
(read-line s))
"ls: /sbin/ls /usr/bin/ls /usr/share/man/man1.Z/ls.1"
NIL
CL-USER 40 > (setf *ls* (sys:open-pipe "dir"))
#<WIN32::TWO-WAY-PIPE-STREAM 205F03F4>
CL-USER 41 > (loop while
(print (read-line *ls* nil nil)))
" Volume in drive Z is lispsrc"
" Volume Serial Number is 82E3-1342"
""
" Directory of Z:\\v42\\delivery-tests"
""
"20/02/02 11:57a <DIR> ."
"20/02/02 11:57a <DIR> .."
"14/02/02 07:04p 6,815,772 othello.exe"
"14/02/02 07:07p 6,553,628 hello.exe"
" 4 File(s) 13,369,400 bytes"
" 3,974,103,040 bytes free"
NIL
NIL
CL-USER 42 > (close *ls*)
T