IPC::RunExternal - Execute an external command conveniently by hiding the details of IPC::Open3.
version 0.102
use IPC::RunExternal; my $external_command = 'ls -r /'; # Any normal Shell command line my $stdin = q{}; # STDIN for the command. Must be an initialised string, e.g. q{}. my $timeout = 60; # Maximum number of seconds before forced termination. my %parameter_tags = (print_progress_indicator => 1); # Parameter tags: # print_progress_indicator [1/0]. Output something on the terminal every second during # the execution, to tell user something is still going on. # progress_indicator_char [*], What to print, default is '#'. # execute_every_second [&], instead of printing the same everytime, # execute a function. The first parameters to this function is the number of seconds passed. my ($exit_code, $stdout, $stderr, $allout); ($exit_code, $stdout, $stderr, $allout) = runexternal($external_command, $stdin, $timeout, \%parameter_tags); # Parameter tags opened: ($exit_code, $stdout, $stderr, $allout) = runexternal($external_command, $stdin, $timeout, { progress_indicator_char => q{#} }); # Print `date` at every 10 seconds during execution my $print_date_function = sub { my $secs_run = shift; if($secs_run % 10 == 0) { print `/bin/date`; } }; ($exit_code, $stdout, $stderr, $allout) = runexternal($external_command, $stdin, $timeout, { execute_every_second => $print_date_function });
IPC::RunExternal is for executing external operating system programs more conveniently than with `` or system(), and without all the hassle of IPC::Open3.
``
system()
IPC::RunExternal allows:
This package is currently being developed so changes in the API and functionality are possible.
Requires Perl version 5.6.2.
Exports routine runexternal().
Working in MSWin not guaranteed, might also not work in other Unices / OpenVMS / other systems. Tested only in Linux. Depends mostly on IPC::Open3 working in the system.
Run an external (operating system) command.
Mikko Koivunalho <mikkoi@cpan.org>
This software is copyright (c) 2011 by Mikko Koivunalho.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install IPC::RunExternal, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IPC::RunExternal
CPAN shell
perl -MCPAN -e shell install IPC::RunExternal
For more information on module installation, please visit the detailed CPAN module installation guide.