Next Previous Up Top Contents Index

18 The SYSTEM Package

open-pipe

Function

Package

system

Syntax

open-pipe command &key {keyword value}* => stream

The valid keyword/value pairs are:

:direction {:input|:output|:io}

:element-type element-type

:interrupt-off {t|nil}

:shell-type

Arguments

command

A string

direction

A keyword. Either:input or:io.

element-type

A symbol.

interrupt-off

A boolean.

shell-type

A shell type.

Values

stream

A file stream.

Description

The behaviour ofopen-pipe is analogous to that ofpopen 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 withopen. The default value isstring-char.
interrupt-off, ift, ensures that Ctrl+C (SIGINT) to the LispWorks image is ignored by the subprocess.
shell-type specifies the type of UNIX shell to run.
Examples

SYSTEM 106 > (setq s (open-pipe "ls"))

#<Pipe stream "ls">

SYSTEM 107 > (read-line s)

"#draw-string.lisp#" NIL

SYSTEM 108 > (read-line s)

"#drawing-state.lisp#" NIL

SYSTEM 109 >

The following example shows you how to use bidirectional pipes.
SYSTEM 17 > (with-open-stream
                (s (open-pipe "/bin/csh"
                             :direction :io
                             :buffered nil))
                (write-line "whoami" s)
                (read-line s))
"andrews@arrakis [users/andrews]> andrews"
NIL

SYSTEM 18 >

See also

call-system
call-system-showing-output

LispWorks Reference Manual - 15 Oct 1998

Next Previous Up Top Contents Index

Generated with Harlequin WebMaker