NAME

App::Framework::Feature::Run - Execute external commands

SYNOPSIS

use App::Framework '+Run' ;

DESCRIPTION

Provides for external command running from within an application.

DOCUMENTATION TO BE COMPLETED

Arguments

Return code

Command output

Timeout

Callbacks

Examples

$app->run(
	'cmd' 		=> "perl t/test/runtest.pl", 
) ;

$app->run(
	'cmd' 		=> "perl t/test/runtest.pl", 
	'progress'	=> \&progress,
) ;

my $sleep = 10 ;
$expected = \@data ;
$delay = $sleep ;
$run->run_cmd("perl t/test/runtest.pl", 
	'progress'	=> \&progress,
	'args'		=> "ping $sleep",
	'timeout'	=> $sleep,
) ;

Fields

cmd - command string (program name)

The program to run

args - any optional program arguments

String containing program arguments (may be specified as part of the 'cmd' string instead)

timeout - optional timeout time in secs.

When specified causes the program to be run as a forked child

nice - optional nice level
check_results - optional results check subroutine

results check subroutine which should be of the form:

check_results($results_aref)

Where: $results_aref = ARRAY ref to all lines of text

Subroutine should return 0 = results ok; non-zero for program failed.

progress - optional progress subroutine

progress subroutine which should be in the form:

 progress($line, $linenum, $state_href)
					   

Where: $line = line of text $linenum = line number (starting at 1) $state_href = An empty HASH ref (allows progress routine to store variables between calls)

status - Program exit status

Reads as the program exit status

results - Program results

ARRAY ref of program output text lines

norun - Flag used for debug

Evaluates all parameters and prints out the command that would have been executed

CONSTRUCTOR

new([%args])

Create a new Run.

The %args are specified as they would be in the set method (see "Fields").

CLASS METHODS

init_class([%args])

Initialises the Run object class variables.

OBJECT METHODS

access([%args])

Provides access to the feature. Operates in two modes:

* if no arguments are provided, returns the feature object * if arguments are provided, calls the 'run()' method, then returns the object

run([%args])

Execute a command, return exit status (0=success)

run_results([%args])

Execute a command, return output lines

run_cmd($cmd, [%args])

Execute a specified command, return exit status (0=success)

run_cmd_results($cmd, [%args])

Execute a specified command, return output lines

clear_args()

Clear out command args (ready for calls of the add_args method)

add_args($args)

Add arguments from parameter $args.

If $args is scalar, append to existing arguments with a preceding space If $args is an array, append each to args If $args is a hash, append the args as an 'option' / 'value' pair. If 'value' is not defined, then just set the option.

check_args()

Ensure arguments are correct

Display the full command line as if it was going to be run

DIAGNOSTICS

Setting the debug flag to level 1 prints out (to STDOUT) some debug messages, setting it to level 2 prints out more verbose messages.

AUTHOR

Steve Price <sdprice at cpan.org>

BUGS

None that I know of!