Pipe:
Filter:
Classes | Files

Pipe : UnixFILE : IOStream : Stream : AbstractFunction : Object

pipe stdin to, or stdout from, a UNIX shell command
Source: File.sc

Description

Pipe stdin to, or stdout from, a UNIX shell command. Pipe treats the shell command as if it were a UnixFILE, and returns nil when done. See UnixFILE for details of the access methods. Pipe must be explicitly closed. Do not rely on the garbage collector to do this for you!

Class Methods

Pipe.new(commandLine, mode)

Arguments:

commandLine

A String representing a valid shell command.

mode

A String representing the mode. Valid modes are "w" (pipe to stdin) and "r" (pipe from stdout).

Pipe.argv(args, mode)

Arguments:

args

A SequenceableCollection containining strings where the first string is the path to the executable to be run and all other strings are passed as arguments to the executable. This method starts the process directly without using a shell.

mode

A String representing the mode. Valid modes are "w" (pipe to stdin) and "r" (pipe from stdout).

Inherited class methods

Undocumented class methods

Pipe.call(command, onSuccess, onError, maxLineLength: 4096)

Pipe.callSync(command, onSuccess, onError, maxLineLength: 4096)

Instance Methods

.open(commandLine, mode)

Open the file.

Arguments:

commandLine

A command line String passed to popen.

mode

A String passed to popen, so should be one of: "r","w"

.openArgv(args, mode)

Open the file.

Arguments:

args

A SequenceableCollection containining strings where the first string is the path to the executable to be run and all other strings are passed as arguments to the executable. This method starts the process directly without using a shell.

mode

A String passed to popen, so should be one of: "r","w"

.close

Closes the pipe, waiting for the command to finish. You must do this explicitly before the Pipe object is garbage collected.

Returns:

The exit status of the command (an Integer).

Inherited instance methods

Examples

without using a shell:

A more time-intensive request: