execWithOutput


Description:

public static string? execWithOutput (string cmd, string[] args)

Executes an external command and returns stdout on success.

Example:

    string? out = Process.execWithOutput ("sh", { "-c", "printf 'hello'" });
assert (out == "hello");

Parameters:

cmd

command path or executable name.

args

command arguments.

Returns:

captured stdout when exit status is 0, otherwise null.