Command::Template::Runner::Record
use Command::Template 'cr'; my $runner = cr(qw{ ls [options=-l] <dir> }); my $run = $runner->run(options => '-la', dir => '/usr'); say $run->stdout if $run->success; say $run->stderr if $run->failure; # same as ! $run->success say 'killed by signal ' . $run->signal if $run->signal; say 'exit value was' . $run->exit_code;
This class represents the outcome of a single run by Command::Template.:Runner; it can be used to investigate the outcome in all its parts (e.g. error conditions, what was printed on standard output, what was printed as standard error, etc.
my $aref = $run->command;
Returns a reference to an array containing the expanded command that was executed.
my $s = $run->command_as_string;
Returns a stringification of the whole command (assumes using "command");
my $ec = $run->exit_code;
The process's exit code.
say 'failed' if $run->failed;
Check whether the invocation failed. It is the opposite of "success".
my $integer = $run->full_exit_code;
The *full* exit code, including the exit code in the higher byte of the pair and the termination signal in the lower.
my $text = $run->merged;
A mix of standard error and standard output. At the moment first standard error, then standard output.
my $object = Command::Template::Runner::Record->new($data);
Constructor (it is not generally meant to be used by end customers).
my $href = $run->options;
A reference to the hash set for options while running. This might e.g. contain a key stdin with the standard input provided to the child process.
stdin
my $sig = $run->signal;
The signal integer code, in case the child process was terminated due to an unhandled signal.
my $text = $run->stderr;
What was sent out to standard error.
my $text = $run->stdout;
What was sent out to standard output.
say 'everything ok' if $run->success;
Check whether the invocation succeeded. It is the opposite of "failure":
my $bool = $run->timed_out;
Check whether the operation timed out or not.
my $int = $run->timeout;
Returns the timeout value. This is 0 if no timeout was set or the command exited without reaching the timeout.
See documentation for Command::Template.
To install Command::Template, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Command::Template
CPAN shell
perl -MCPAN -e shell install Command::Template
For more information on module installation, please visit the detailed CPAN module installation guide.