ASNMTAP

 view release on metacpan or  search on metacpan

applications/htmlroot/cgi-bin/admin/generateConfig.pl  view on Meta::CPAN

                    /^STOP$/    && do {
                      $exitCurrentServer = ( ( $capture =~ /^(Stop:(?:\s)*'(Collector|Display)(?:\s)*(.)*'(?:\s)*...|'(Collector|Display)(?:\s)*(.)*'(?:\s)*already stopped)$/ ) ? 0 : 1 );
                      last; };
                    /^START$/   && do {
                      $exitCurrentServer = ( ( $capture =~ /^Start:(?:\s)*'(Collector|Display)(?:\s)*(.)*'(?:\s)*...$/ ) ? 0 : 1 );
                      $proccessNextLine++ unless ( $exitCurrentServer );
                      last; };
                    /^CRONTAB$/ && do { last; };
                    /^REMOVE$/  && do { last; };
                    $exitCurrentServer = 1;
                  }
                } elsif ( $proccessNextLine ) {
                  $commandsTODO .= "\n        <tr bgcolor=\"$COLORSTABLE{STARTBLOCK}\"><td><FONT COLOR=\"cyaan\">proccess next line: $proccessNextLine - $capture</FONT></td></tr>";
                } else {
                  my $match = 0;

                  if ( $debug eq 'T' ) {
                    for ( $capture ) {
                      /kill:(?:\s)*\((?:\d)*\)(?:\s)*-(?:\s)*No such process$/ && do { $match = 1; $exitCurrentServer = 1; last; };
                      /^cat:(?:\s)*cannot(?:\s)*open(?:\s)*(.)*\.pid$/         && do { $match = 2; $exitCurrentServer = 1; last; };
                    }
                  } else {
                    $exitCurrentServer = 1;
                  }

                  $commandsTODO .= "\n        <tr bgcolor=\"$COLORSTABLE{STARTBLOCK}\"><td><FONT COLOR=\"cyaan\">match rule: $match - $capture</FONT></td></tr>";
                }
              }

              $color = '#99CC99' unless ( $exitCurrentServer );
            } else {
              $exitCurrentServer = 1;

              foreach my $capture ( @capture ) {
                $capture =~ s/\r$//g;
                $capture =~ s/\n$//g;
                next unless ( defined $capture );

                my $match = '0';

                if ( $debug eq 'T' ) {
                  for ( $capture ) {
                    /^ksh:(?:\s)*(.)*:(?:\s)*not found$/                  && do { $match = 127; last; }; # exit_value = 127
                    /^ksh:(?:\s)*(.)*:(?:\s)*cannot execute$/             && do { $match = 126; last; }; # exit_value = 126
                    /^scp:(?:\s)*(.)*:(?:\s)*No such file or directory$/  && do { $match = 1;   last; }; # exit_value = 1
                    $match = '?';
                  }
                }

                $commandsTODO .= "\n        <tr bgcolor=\"$COLORSTABLE{STARTBLOCK}\"><td><FONT COLOR=\"cyaan\">match rule: $match = exit_value: $exit_value - $capture</FONT></td></tr>";
              }
            }

            my $prefix = ( ( $debug eq 'T' ) ? "A) '$label' [$_id] " : '' );
            $commandsTODO .= "\n        <tr bgcolor=\"$COLORSTABLE{ENDBLOCK}\"><td><b><FONT COLOR=\"$color\">${prefix}${command}</FONT></b></td></tr>";
          } else { # implementatie moet nog gebeuren
            my $color = ( ( $auto == 1 ) ? '#99CC99' : 'white');
            my $prefix = ( ( $debug eq 'T' ) ? "I) '$label' [$_id] " : '' );
            $commandsTODO .= "\n        <tr bgcolor=\"$COLORSTABLE{ENDBLOCK}\"><td><b><FONT COLOR=\"$color\">${prefix}${command}</FONT></b></td></tr>";
          }
        } else { # no action required
          my $prefix = ( ( $debug eq 'T' ) ? "N) '$label' [$_id] " : '' );
          $commandsTODO .= "\n        <tr bgcolor=\"$COLORSTABLE{ENDBLOCK}\"><td><FONT COLOR=\"#99CC99\">${prefix}${command}</FONT></td></tr>";
        }

        $commandsExecuted++ unless ( $exitCurrentServer );
      }
    }
  }

  $statusMessage .= $commandsTODO if (defined $commandsTODO);

# APE #
# unless ($details)
#   $action = 'errorView' unless ( $commandsToExecute eq $commandsExecuted );
# }

  return ($statusMessage);
}

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

sub do_system_call {
  my ($command, $debug) = @_;

  my ($stdout, $stderr, $exit_value, $signal_num, $dumped_core, $status, $statusMessage);

  if ($CAPTUREOUTPUT) {
    use IO::CaptureOutput qw(capture_exec);
   ($stdout, $stderr) = capture_exec("$command");
  } else {
    system ("$command"); $stdout = $stderr = '';
  }

  if ( $debug eq 'T' ) {
    $exit_value  = $? >> 8;
    $signal_num  = $? & 127;
    $dumped_core = $? & 128;

    $statusMessage  = "<tr bgcolor=\"$COLORSTABLE{STARTBLOCK}\"><td>$command: ";
    $statusMessage .= ( $exit_value == 0 && $signal_num == 0 && $dumped_core == 0 && $stderr eq '' ) ? 'Success' : "Failed '$stderr'";
    $statusMessage .= "</td></tr>";
  } else {
    $statusMessage = '';
  }

  return ($statusMessage);
}

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

sub system_call {
  my ($command, $parameters, $debug) = @_;

  my $doSystemCall = 0;
  my $statusMessage = '';

  if ( $command eq "mkdir" ) {
    $doSystemCall = 1 unless ( -e "$parameters" );
  } elsif ( $command eq "rm -rf" ) {
    if ($parameters =~ /$APPLICATIONPATH\/tmp\/$CONFIGDIR\// and -e "$parameters") { $doSystemCall = 1; }



( run in 1.549 second using v1.01-cache-2.11-cpan-39bf76dae61 )