From c17328d39d45a386227eced20e9c0f2f9449603f Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 13 Nov 2019 14:21:09 +0100 Subject: [PATCH] Pandora Agent RCMD --- pandora_agents/unix/pandora_agent | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 7a84c47ce1..63cd9e8374 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -318,8 +318,7 @@ sub read_file { my $path = shift; my $_FILE; - if( !open($_FILE, "<".$path) ) { - print ">> Failed to open $path ".`whoami`."\n"; + if( !open($_FILE, "<", $path) ) { # failed to open, return undef return undef; } @@ -1535,15 +1534,20 @@ sub report_command { sub execute_command_block { my ($commands, $std_files) = @_; - $std_files = '' unless defined ($std_files); - return 0 if ref($commands) ne "ARRAY"; - my $err_level; + $std_files = '' unless defined ($std_files); - foreach my $comm (@{$commands}) { - `($comm) $std_files`; + if (ref($commands) ne "ARRAY") { + `($commands) $std_files`; + print "($commands) $std_files\n"; $err_level = $?>>8; - last unless ($err_level == 0); + } else { + foreach my $comm (@{$commands}) { + `($comm) $std_files`; + print $comm. '=> ' . ($?>>8)."\n"; + $err_level = $?>>8; + last unless ($err_level == 0); + } } return $err_level;