ePages 6.14.0 - DE_EPAGES/Core/API/SystemCommand.pm

Package DE_EPAGES::Core::API::SystemCommand

This Module starts an external process.

@EXPORT_OK
SystemCommand
RunCommandsInDir

Functions

RunCommandsInDir
SystemCommand

RunCommandsInDir

Execute files ending in *.sh, *.cmd or *.bat in $Dir with $Args

Syntax
$Status = RunCommandsInDir($Dir, $Args, $Output)
Input
$Dir (string)
directory containing files
$Args (ref.array)
additional arguments for SystemCommand()
$Output (ref.string)
write output into string
Return
$Status (integer)
0 - success ; else - failue

SystemCommand

Executes a system command and throws an error if the command does not terminate with exit code 0. Possible error codes are:

Syntax
SystemCommand( $CommandLine, $hOptions );
SystemCommand( $aCommandLine, $hOptions );
$Output = SystemCommand( $CommandLine, $hOptions );
Example
SystemCommand( ['java', '-version'], { 'Print' => 1 });
$Output = SystemCommand( "perl -v", { 'Capture' => 1 });
Input
$CommandLine (string)
command with paramters
$aCommandLine (ref.array)
command with paramters, first array element is the executable
$hOptions (ref.hash)
(optional) keys are:
  • Print - print the command line before execution - boolean
  • Capture - captures STDOUT and returns it as string

Return
$Output (string)
command output (from STDOUT), only if Capture is true