open-pipe command &key { keyword value }* => stream
The valid keyword/value pairs are:
The behaviour of open-pipe
is analogous to that of popen
in the UNIX library. It creates a unidirectional pipe to/from a subprocess and returns a stream. The stream can be read from or written to as appropriate.
The command argument passes a shell command as a string.
direction is a keyword for the stream direction. The default value is :input
. Bidirectional (i/o) pipes may be created by setting this keyword to :io
. See the example below.
element-type specifies the type of the stream as with open
. The default value is string-char
.
interrupt-off , if t
, ensures that Ctrl+C (SIGINT) to the LispWorks image is ignored by the subprocess.
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