add options for backtick function

This commit is contained in:
Colin Gagnaire 2019-04-26 18:40:51 +02:00
parent 1dc9dd6e56
commit d64643e575
2 changed files with 24 additions and 17 deletions

View File

@ -120,6 +120,11 @@ sub unix_execute {
my $args = []; my $args = [];
my ($lerror, $stdout, $exit_code); my ($lerror, $stdout, $exit_code);
my $redirect_stderr = 1;
$redirect_stderr = $options{redirect_stderr} if (defined($options{redirect_stderr}));
my $wait_exit = 1;
$wait_exit = $options{wait_exit} if (defined($options{wait_exit}));
# Build command line # Build command line
# Can choose which command is done remotely (can filter and use local file) # Can choose which command is done remotely (can filter and use local file)
if (defined($options{options}->{remote}) && if (defined($options{options}->{remote}) &&
@ -151,16 +156,16 @@ sub unix_execute {
($lerror, $stdout, $exit_code) = backtick( ($lerror, $stdout, $exit_code) = backtick(
command => $cmd, command => $cmd,
timeout => $options{options}->{timeout}, timeout => $options{options}->{timeout},
wait_exit => 1, wait_exit => $wait_exit,
redirect_stderr => 1 redirect_stderr => $redirect_stderr
); );
} else { } else {
($lerror, $stdout, $exit_code) = backtick( ($lerror, $stdout, $exit_code) = backtick(
command => $cmd, command => $cmd,
arguments => [@$args, $sub_cmd], arguments => [@$args, $sub_cmd],
timeout => $options{options}->{timeout}, timeout => $options{options}->{timeout},
wait_exit => 1, wait_exit => $wait_exit,
redirect_stderr => 1 redirect_stderr => $redirect_stderr
); );
} }
} else { } else {
@ -172,8 +177,8 @@ sub unix_execute {
($lerror, $stdout, $exit_code) = backtick( ($lerror, $stdout, $exit_code) = backtick(
command => $cmd, command => $cmd,
timeout => $options{options}->{timeout}, timeout => $options{options}->{timeout},
wait_exit => 1, wait_exit => $wait_exit,
redirect_stderr => 1 redirect_stderr => $redirect_stderr
); );
} }

View File

@ -132,7 +132,9 @@ sub execute {
sudo => $self->{option_results}->{sudo}, sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command}, command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path}, command_path => $self->{option_results}->{command_path},
command_options => $options{cmd_options}); command_options => $options{cmd_options},
redirect_stderr => 0
);
my $raw_results; my $raw_results;