Skip to main content

Script Class

Package: GHIElectronics.Endpoint.Core
Namespace: GHIElectronics.Endpoint.Core

Runs an external program and collects what it prints. Used internally by the Endpoint libraries where a direct API is not yet available; prefer the direct API where one exists.

class Script {};

Nested Types​

TypeKindSummary
Script.OutputDataReceivedEventHandlerDelegateSignature for the Script.OutputDataReceived event.

Constructors​

Script(string filename, string workingdir, string arguments)​

Script(const std::string& filename, const std::string& workingdir, const std::string& arguments);

Prepares to run filename with the given arguments and working directory.

ParameterTypeDescription
filenamestringPath to the program, or a name that PATH resolves.
workingdirstringWorking directory for the program; empty for the current one.
argumentsstringCommand-line arguments as a single string, split by the shell convention.

Properties​

Error​

std::string Error() const;

Everything the program has printed to standard error so far, newline-separated.

Returns string

ExitCode​

int32_t ExitCode() const;

The program's exit code; -1 if it could not be started

Returns int

IsBusy​

bool IsBusy() const;

True while the program is running (between Script.Start and the program's exit).

Returns bool

Output​

std::string Output() const;

Everything the program has printed to standard output so far, newline-separated.

Returns string

Methods​

Start(bool waitforexit)​

void Start(bool waitforexit);

Starts the program and, unless told otherwise, waits until it ends

Stop()​

void Stop();

Ends the program (and what it started)

Events​

OutputDataReceived​

Core::Event<...> OutputDataReceived;

Each line the program prints, as it prints it