Help language development. Donate to The Perl Foundation

Proc::Easy zef:tbrowder last updated on 2021-12-10
[![Actions Status](](


**Proc::Easy** - Provides routine `run-command` to ease using Raku's **Proc** class.

NOTE: This module replaces the `run-command` portion of the deprecated module `Proc::More`. Note also the API has changed slightly: the previous `:$all` option was removed and its behavior is now the default (i.e., all three of the output parameter values are returned as a list of three elements unless only one is selected as an option).


    use Proc::Easy;
    my $cmd = "some-user-prog arg1 arg2";
    my $other-dir = $*TMPDIR";
    my ($exitcode, $stderr, $stdout) = run-command $cmd, :dir($other-dir);


**Proc::Easy** is designed to make using the `run` routine from class `Proc` easier for the usual, simple case when the myriad ways to use `Proc`'s `run` are not required.

sub run-command

sub run-command(Str:D $cmd,
		:$dir, # run command in dir 'dir'
	       ) is export {...}

### Parameters:

  * `$cmd` - A string that contains a command suitable for using Raku's `run` routine

  * `:$exit` - Returns the exit code which should be zero (false) for a successful command execution

  * `:$err` - Returns `stderr`

  * `:$out` - Returns `stdout`

  * `:$dir` - Runs the command in directory 'dir'

  * `:$debug` - Prints extra info to stdout AFTER the `proc` command

### Returns:

A three-element list of the exit code and results from `stderr` and `stdout`, respectively. Either of the three may be selected individually if desired. (If more than one is selected, only one is returned in the order of exit code, `stderr`, or `stdout`.) There is also the capability to send debug messages to `stdout` by including the `:$debug` option.


Tom Browder <[email protected]>


Copyright © 2017-2021 Tom Browder

This library is free software; you may redistribute or modify it under the Artistic License 2.0.