IPC::Open3::Callback::CommandRunner - A utility class that wraps IPC::Open3::Callback with available output buffers and an option to die on failure instead of returning exit code.
use IPC::Open3::Callback::CommandRunner; my $command_runner = IPC::Open3::Callback::CommandRunner->new(); my $exit_code = $command_runner->run( 'echo Hello, World!' ); eval { $command_runner->run_or_die( $command_that_might_die ); }; if ( $@ ) { print( "command died: $@\n" ); }
Adds more convenience to IPC::Open3::Callback by buffering output and error if needed and dieing on failure if wanted.
The constructor creates a new CommandRunner.
Returns the contents of the err_buffer from the last call to run or run_or_die.
Returns the contents of the err_buffer from the last call to run or run_or_die.
Will run the specified command with the supplied arguments by passing them on to run_command. Arguments can be embedded in the command string and are thus optional.
If the last argument to this method is a hashref (ref(@_[-1]) eq 'HASH'
), then it is treated as an options hash. The supported allowed options are the same as run_command plus:
If true, a callback will be generated for STDOUT
that buffers all data and can be accessed via out_buffer()
If true, a callback will be generated for STDERR
that buffers all data and can be accessed via err_buffer()
Returns the exit code from the command.
The same as run exept that it will die
on a non-zero exit code instead of returning the exit code.
Lucas Theisen (lucastheisen@pastdev.com)
Copyright 2013 pastdev.com. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.