getOutput

Get the output of a shell command after passing it some input.

string
getOutput
(
string command
,
string input = ""
)

Parameters

command
Type: string

Shell command to run.

input
Type: string

Input to pass to the command via stdin. Defaults to no input.

Return Value

Type: string

A string containing all stdout output from the given commands execution.

Examples

A simple example for giving a program input programatically and returning the result.

assert (getOutput ("awk '{print tolower($0)}'", "TEXT") == "text");

Meta