Index: ossp-pkg/tabea/tabea.cgi RCS File: /v/ossp/cvs/ossp-pkg/tabea/tabea.cgi,v rcsdiff -q -kk '-r1.20' '-r1.21' -u '/v/ossp/cvs/ossp-pkg/tabea/tabea.cgi,v' 2>/dev/null --- 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 .= "
" . $cgi->param('editfile') . "
" ; + $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 .= "Missing filename

\n" . $cgi->submit(-name => 'dialog', -value => 'Back') ; } + return $text; } ######################################################################################## +######################################################################################## +sub save { +######################################################################################## + my ( $file, $edittext) = @_; + my $text = ''; + my $fileout; + + $text= "" . + "Save File: $file

\n" . + "
" . + "

" ; + + $fileout = IO::File->new(">$file"); + if (defined $fileout) { + print $fileout $edittext; + $fileout->close; + } else { + $text .= "Cannot save file

\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 .= "Missing filename

\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= "" . + "Running Configuration: $rpath

\n" . + "
" . + "

" . + "Run command: " . $rcommand . "
" ; + + 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 .= "Run command not working

\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)) . "" . $titletext . ":

\n" . "
" . @@ -862,13 +955,14 @@ $cgi->submit(-name => 'dialog', -value => 'Back') . " "; if ($mode eq 'w') { - $page .= " " . + $text .= " " . $cgi->submit(-name => 'dialog', -value => 'Save') . " "; } - $page .= " " . + $text .= " " . " " . "" ; + return $text; } ########################################################################################