OSSP CVS Repository

ossp - Check-in [2138]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 2138
Date: 2002-May-16 17:54:59 (local)
2002-May-16 15:54:59 (UTC)
User:ps
Branch:
Comment: Appended run section
Tickets:
Inspections:
Files:
ossp-pkg/tabea/tabea.cgi      1.20 -> 1.21     104 inserted, 10 deleted

ossp-pkg/tabea/tabea.cgi 1.20 -> 1.21

--- tabea.cgi    2002/05/16 12:22:05     1.20
+++ tabea.cgi    2002/05/16 15:54:59     1.21
@@ -236,7 +236,12 @@
     $page .= $cgi->endform;
 } 
 elsif ($dialog eq 'Save') {
-    ## FIXME
+    #  enter save form
+    $page .= $cgi->startform( -method => "POST", -action => $cgi->url(-full => 1));
+    $page .= "<br>" . $cgi->param('editfile') . "<br>" ;
+    $page .= &save($cgi->param('editfile'), $cgi->param('editwindow'));
+    $page .= $cgi->hidden(-name => 'password', -default => $password ) ;
+    $page .= $cgi->endform;
 }
 elsif ($dialog eq 'View') {
     #   enter View form
@@ -301,6 +306,16 @@
     $page .= $cgi->hidden(-name => 'password', -default => $password ) ;
     $page .= $cgi->endform;
 }
+elsif ($dialog eq 'Run' ) {
+    $page .= $cgi->startform( -method => "POST", -action => $cgi->url(-full => 1));
+    $page .= &run($cgi->param('configslist') );
+    $page .= $cgi->hidden(-name => 'password', -default => $password ) ;
+    $page .= $cgi->endform;
+}
+else {
+    die "no correct dialog found";
+}
+
 
 } else {
     die "no configuration found";
@@ -367,20 +382,50 @@
 ########################################################################################
 sub edit {
 ########################################################################################
-    my ($file) = @_;
+    my ($editfile) = @_;
     my $text;
     #   enter Edit form
-    if($file) {
-        my $filename = $cfghash{'BaseDir'} . $cfghash{'ConfigDir'} . "/" . $file;
-        &editconfig($filename, 'w', $username);
+   
+ 
+
+    if($editfile) {
+        my $filename = $cfghash{'BaseDir'} . $cfghash{'ConfigDir'} . "/" . $editfile;
+        $text .=&editconfig($filename, 'w', $username).
+        $cgi->hidden(-name => 'editfile', -default => $filename ) ;
     } else {
         $text .= "<font color=red>Missing filename<br><br>\n" .
         $cgi->submit(-name => 'dialog', -value => 'Back') ;
     }
+    
     return $text;
 }
 ########################################################################################
 
+########################################################################################
+sub save {
+########################################################################################
+    my ( $file, $edittext) = @_;
+    my $text = '';
+    my $fileout; 
+
+    $text= "<font size=+2>" .
+    "Save File: $file<br><br>\n" .
+    "</font>" .
+    "<br><br>" ;
+
+    $fileout = IO::File->new(">$file");
+    if (defined $fileout) {
+        print $fileout $edittext;
+        $fileout->close;
+    } else {
+        $text .= "<font color=red>Cannot save file<br><br>\n" ;
+    }
+
+    $text .= $cgi->submit(-name => 'dialog', -value => 'Back');
+    
+    return $text;
+}
+########################################################################################
 
 ########################################################################################
 sub view {
@@ -390,7 +435,7 @@
     
     if ($file) {
         my $filename = $cfghash{'BaseDir'} . $cfghash{'ConfigDir'} . "/" . $cgi->param('templatelist');
-        &editconfig($filename, 'r', $username);
+        $text .= &editconfig($filename, 'r', $username);
     } else {
         $text .= "<font color=red>Missing filename<br><br>\n" .
         $cgi->submit(-name => 'dialog', -value => 'Back') ;
@@ -660,6 +705,54 @@
 ########################################################################################
 
 
+########################################################################################
+sub run {
+########################################################################################
+    my ( $runfile ) = @_;
+    my $text = '';
+    my $rpath = $cfghash{'BaseDir'} . $cfghash{'ConfigDir'} . "/" . $runfile;
+    my $rcommand = $cfghash{'ExecuteCommand'};
+    my $output = "/tmp/" .  $cfghash{'ExecuteTempFile'};
+    my $fileoutput;
+    my $outputtext = '';
+
+    $rcommand =~ s|%{profile}%|$rpath|s;
+
+    if (-e $output) {
+        system("/bin/rm $output");
+    }
+
+
+    $text= "<font size=+2>" .
+    "Running Configuration: $rpath<br><br>\n" .
+    "</font>" .
+    "<br><br>" .
+    "Run command: " . $rcommand . "<br>" ;
+
+    system("$rcommand > $output 2>&1");
+
+    $fileoutput = IO::File->new("<$output");
+    if(defined $fileoutput) {
+        while (<$fileoutput>) {
+            $outputtext .= $_;
+        }
+        $fileoutput->close();
+
+        my $outputhash ={   -name => 'outputwindow',
+                            -default => $outputtext,
+                            -rows    => 40,
+                            -columns => 80
+        };
+        $outputhash->{readonly}="";
+        $text .= $cgi->textarea($outputhash);
+     } else {
+         $text .= "<font color=red>Run command not working<br><br>\n" ;            
+     }
+
+     $text .= $cgi->submit(-name => 'dialog', -value => 'Back');
+}
+########################################################################################
+
 
 ########################################################################################
 sub copy {
@@ -830,7 +923,7 @@
 
     $filein = IO::File->new("<$file");
     while(<$filein>) { $text .= $_; }
-    $filein->close; 
+    $filein->close(); 
 
 
     if ($mode eq 'w') {
@@ -847,7 +940,7 @@
     if ($mode eq 'r') {
         $textahash->{readonly}="";
     }
-    $page .= $cgi->startform( -method => "POST", -action => $cgi->url(-full => 1)) .
+    $text .= $cgi->startform( -method => "POST", -action => $cgi->url(-full => 1)) .
     "<font size=+2>" .
     $titletext . ":   <br><br>\n" .
     "</font>" .
@@ -862,13 +955,14 @@
     $cgi->submit(-name => 'dialog', -value => 'Back') .
     "   </td>";
     if ($mode eq 'w') {
-    $page .= "   <td>" .
+    $text .= "   <td>" .
     $cgi->submit(-name => 'dialog', -value => 'Save') .
     "   </td>";
     }
-    $page .= "  <td>" .
+    $text .= "  <td>" .
     " </td>" .
     "</table>" ;
 
+    return $text;
 }
 ########################################################################################

CVSTrac 2.0.1