#!/usr/bin/perl
# STTA Rev. 1.3 Copyright (c) 2001-2004 Jesús Pérez Lorenzo  --- license GNU GPL
# stta: (@#) 1.31051043346- [2004_01_29_102036]

require './stta-lib.pl';
if ( ! $access{'monitor'} )   { &redirect("index.cgi"); }
if ( $config{'has_monitor'} ne "true" )  { &redirect("index.cgi"); }
&foreign_require("proc", "proc-lib.pl");    
&ReadParse();
if ( ! $in{aliasAct} ){ &redirect("mon_selact.cgi?sort_on=script&form=runact"); }
$aliasAct=$in{aliasAct};
$descrip=$in{descrip};
$cmd=$in{cmd};
%h_actions=&list_actions();
&headerstta($text{'index_runact'}, "", "monitor_act",undef,1,0,"$text{'headpage_right'}"."$text{'head_logout'}",undef,undef,"$text{head_below}" );
print "<table width=100% border>\n";
print "<tr $tb> <td><font color='$revtext'><b>$text{'titidx_runact'}: $aliasAct - $descrip </b></font></td> </tr>\n";
print "<tr $cb><td><table width=100% border=0>\n";
if ( $h_actions{$aliasAct}->{'alias'} ne $aliasAct ) {
         $err_msg=$text{'list_errno'};
         &footHere;
         exit;
}
print "</td></tr>\n";
$f_path=$config{'monitor_scripts_path'}."/".$h_actions{$aliasAct}->{'script'};

if (  -x $f_path ) {
      print "<tr><td><b>$text{'execute'} </b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>$aliasAct</i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>$descrip</b>\n";
      $str=$f_path;
      $exec_str="$text{execute}: $aliasAct";
      $cmd_str="(descrip)";
      $line_timef="\"".$h_actions{$aliasAct}->{'script'}."\"";
      if (&run_cmd($str)) {
          print "<tr><td><center><b>-- oOo --</b></center></td></tr>\n";
      } else {
          print "<tr><td><b>$text{'index_cmderr'}</b></td></tr>\n";
      }
      print "<tr><td><center>".&text('viewlog_action',$stta_sid)."</td></tr>"; 
    print "<tr><td>";
 } else {
    print &text('file_errerun',$config{'monitor_scripts_path'},$h_actions{$aliasAct}->{'script'}); 
 }
 print " </td></tr>\n";
 print "</table></td></tr></table><hr><p>\n";
 &footer($config{'back_return'},$text{'index'});
 print "<p><p><p>\n";
 do "footer.pl";
 exit;
