NAME
IPC::System::Simple - Call system() commands with a minimum of fuss
SYNOPSIS
use IPC::System::Simple qw(run);
run("foo");
run("foo",@args);
my $exit_value = run([0..5], "foo", @args);
DESCRIPTION
Calling Perl's in-built system()
function is easy, but checking the results can be hard. IPC::System::Simple
aims to make life easy for the common cases of calling system.
IPC::System::Simple
provides a single subroutine, called run
, that executes a command using the same semantics is Perl's built-in system
:
use IPC::System::Simple qw(run);
run("cat *.txt"); # Execute command via the shell
run("cat","/etc/motd"); # Execute command without shell
In the case where the command returns an unexpected status, run
will throw an exception, which is not caught will terminate your program with an error.
Capturing an the exception is easy:
eval {
run("cat *.txt");
};
if ($@) {
print "Something went wrong - $@\n";
}
See the diagnostics section below for more details.
IPC::System::Simple
considers the following to be unexpected, and worthy of exception:
Failing to start entirely (eg, command not found, permission denied).
Returning an exit value other than zero (but see below).
Being killed by a signal.
You may specify a range of values which are considered acceptable return values by passing an array reference as the first argument:
run( [0..5], "cat *.txt"); # Exit values 0-5 are OK
run( [0..255], "cat *.txt"); # Any exit value is OK
The run
subroutine returns the exit value of the process:
my $exit_value = run( [0..5], "cat *.txt");
print "Program exited with value $exit_value\n";
DIAGNOSTICS
- IPC::System::Simple::run called with no arguments
-
You attempted to call
run
but did not provide any arguments at all. - IPC::System::Simple::run called with no command
-
You called
run
with a list of acceptable exit values, but no actual command. - "%s" failed to start: "%s"
-
The command specified did not even start. It may not exist, or you may not have permission to use it. The reason it could not start (as determined from
$!
) will be provided. - "%s" unexpectedly returned exit value %d"
-
The command ran successful, but returned an exit value we did not expect. The value returned is reported.
- "%s" died to signal "%s" (%d)
-
The command was killed by a signal. The name of the signal will be reported, or
UNKNOWN
if it cannot be determined. The signal number is always reported. - Internal error in IPC::System::Simple - "%s" ran without exit value or signal"
-
You've found a bug in
IPC::System::Simple
. It knows your command ran successful, but doesn't know how or why it stopped. Please report this error using the submission mechanism described in BUGS below.
BUGS
Reporting of core-dumps is not yet implemented.
WIFSTOPPED status is not checked.
Signals are not supported under Win32 systems.
Please report bugs to http://rt.cpan.org/Public/Dist/Display.html?Name=IPC-System-Simple .
SEE ALSO
AUTHOR
Paul Fenwick <pjf@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2006 by Paul Fenwick
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 195:
You forgot a '=back' before '=head1'