#!/usr/local/bin/perl # This perl script runs a Dataplot macro on a sample of data # passed via the web form. # # Written by: Alan Heckert # Date: 2/1/2001 $webmaster = "n\.heckert\@nist\.gov"; $root_dir = "/home/heckert/public_html/"; $prog_dir = $root_dir . "bin/"; $file_dir = $root_dir . "pinger/"; $temp_dir = $root_dir . "tmp/"; # #$prog = $prog_dir . "dataplot"; $prog = "dataplot"; $outfile = $temp_dir . "dp.out"; &parse_form_data (*simple_form); $macro = $simple_form{'macro'}; $macro = $file_dir . $macro; $dpdata = $simple_form{'dpdata'}; # #$file4 = "/tmp/runsequence.dat" . $PID; $file4 = $temp_dir . "runsequence.dat"; if ( open (FILE4, ">" . $file4 ) ) { } else { exit(1); } # print FILE4 < $outfile` ; sleep 3; $file3 = $outfile; if ( open (FILE3, $file3 ) ) { } else { exit(1); } if (-e $outfile) { $message = " "; while () { $message = $message . $_ ; } } else { exit(1); } close (FILE3); # $junk = &dataplot_output (0, "Dataplot Output", "$message"); exit (0); sub parse_form_data # # Parse arguments: # 1) Person submitting the comments # 2) SRM file being updated # 3) Comment text # { local (*FORM_DATA) = @_; local ( $request_method, $query_string, @key_value_pairs, $key_value, $key, $value); $request_method = $ENV{'REQUEST_METHOD'}; if ($request_method eq "POST" ) { read (STDIN, $query_string, $ENV{'CONTENT_LENGTH'}); } elsif ($request_method eq "GET") { $query_string = $ENV{'QUERY_STRING'}; } else { &return_error (500, "Server Error", "POST method required"); } @key_value_pairs = split (/&/, $query_string); foreach $key_value (@key_value_pairs) { ($key, $value) = split (/=/, $key_value); $value =~ tr/+/ /; $value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg; if (defined($FORM_DATA{$key})) { $FORM_DATA{$key} = join ("\0", $FORM_DATA{$key}, $value); } else { $FORM_DATA{$key} = $value; } } } sub return_error { local ($status, $keyword, $message) = @_; print "Content-type: text/html", "\n"; print "Status: ", $status, " ", $keyword, "\n\n"; print <CGI Program - Unexpected Error

$keyword


$message Please contact $webmaster for more information. End_of_Error exit(1); } sub dataplot_output { local ($status, $keyword, $message) = @_; print "Content-type: text/html", "\n"; print "Status: ", $status, " ", $keyword, "\n\n"; print < Put Dataplot Output Here

$keyword


$message

End_of_Output return 0; }