enhance libssh pipe
This commit is contained in:
parent
0644f056bc
commit
a15ef6916c
|
@ -111,12 +111,20 @@ sub execute {
|
||||||
$cmd .= $options{command} . ' ' if (defined($options{command}));
|
$cmd .= $options{command} . ' ' if (defined($options{command}));
|
||||||
$cmd .= $options{command_options} if (defined($options{command_options}));
|
$cmd .= $options{command_options} if (defined($options{command_options}));
|
||||||
|
|
||||||
# ssh_pipe useless ? maybe.
|
my $ret;
|
||||||
my $ret = $self->{ssh}->execute_simple(
|
if (!defined($options{ssh_pipe}) || $options{ssh_pipe} == 0) {
|
||||||
|
$ret = $self->{ssh}->execute_simple(
|
||||||
cmd => $cmd,
|
cmd => $cmd,
|
||||||
timeout => $options{timeout},
|
timeout => $options{timeout},
|
||||||
timeout_nodata => $options{timeout}
|
timeout_nodata => $options{timeout}
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
$ret = $self->{ssh}->execute_simple(
|
||||||
|
input_data => $cmd,
|
||||||
|
timeout => $options{timeout},
|
||||||
|
timeout_nodata => $options{timeout}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => $ret->{stdout}, debug => 1) if (defined($ret->{stdout}));
|
$self->{output}->output_add(long_msg => $ret->{stdout}, debug => 1) if (defined($ret->{stdout}));
|
||||||
$self->{output}->output_add(long_msg => $ret->{stderr}, debug => 1) if (defined($ret->{stderr}));
|
$self->{output}->output_add(long_msg => $ret->{stderr}, debug => 1) if (defined($ret->{stderr}));
|
||||||
|
@ -138,6 +146,12 @@ sub execute {
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (defined($options{ssh_pipe}) && $options{ssh_pipe} == 1) {
|
||||||
|
# Last failed login: Tue Feb 25 09:30:20 EST 2020 from 10.40.1.160 on ssh:notty
|
||||||
|
# There was 1 failed login attempt since the last successful login.
|
||||||
|
$content =~ s/^(?:Last failed login:|There was.*?failed login).*?\n//msg;
|
||||||
|
}
|
||||||
|
|
||||||
if ($exit_code != 0 && (!defined($options{no_quit}) || $options{no_quit} != 1)) {
|
if ($exit_code != 0 && (!defined($options{no_quit}) || $options{no_quit} != 1)) {
|
||||||
$self->{output}->add_option_msg(short_msg => sprintf('command execution error [exit code: %s]', $exit_code));
|
$self->{output}->add_option_msg(short_msg => sprintf('command execution error [exit code: %s]', $exit_code));
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
|
|
Loading…
Reference in New Issue