#!/usr/bin/perl -w # UNOLS_office.pl # Analyze UNOLS Office performance evaluation responses $version = "V1.00/September 8, 2005"; $debug = 'no'; print STDERR ("**debug, $0 $version\n") if $debug eq 'yes'; # September 8, 2005 V1.00 Robert C. Groman #Check for data validity #Provide feedback to registrant #Save information in data file(s) unshift (@INC, "/home/rgroman/perllib"); require ('sendmessage.pl'); require ('get_web_form_data.pl'); @email_address_to_get_data = ('rgroman\@whoi.edu'); #@email_address_to_get_data = ('rgroman\@whoi.edu', # 'pwiebe\@whoi.edu'); $directory = "/data1/web_responses/UNOLS"; $response_data_file= $directory . "/activefiles/evaluation"; $workarea= $directory . "/savefiles"; $backup_area= $directory . "/savefiles"; &get_web_form_data ; $error="
"; $warning="
"; $| = 1; print <Confirming your UNOLS Office Performance Evaluation Form Submission

Confirming your UNOLS Office Performance Evaluation Form Submission

BEGIN $all_data = ''; $all_data_export = "Start of UNOLS Evaluation Form:\n"; foreach $key (sort keys %param) { print STDOUT ("

**debug, form data param{",$key, "}=", $param{$key}, "\n

") if $debug eq 'yes'; $param{$key} =~ s/ /_/g ; $param{$key} =~ s/\n/_!n!_/g ; $param{$key} =~ s/\t/_/g ; $param{$key} =~ s/\r/_!r!_/g ; $all_data = $all_data . "\t" . $key . "=" . $param{$key}; $export = $param{$key}; $export =~ s/_/ /g; $export =~ s/!n!/|/g; $all_data_export = $all_data_export . "\n" . $key . "=" . $export; } $all_data =~ s/^\s//g; $all_data_export =~ s/^\s//g; $all_data =~ s/\%0D/ /g; $all_data_export =~ s/\%0D/ /g; $all_data =~ s/%0D/ /g; $all_data_export =~ s/%0D/ /g; $all_data =~ s/\%0A/ /g; $all_data_export =~ s/\%0A/ /g; $all_data =~ s/%0A/ /g; $all_data_export =~ s/%0A/ /g; $all_data_export =~ s/ {2,}/ /g; print STDOUT ("

**debug, form all_data=$all_data

\n") if $debug eq 'yes'; #Make copies of all files $unique=`date +%Y%b%d_%I%M%S`; chomp $unique; $backupreg="$backup_area/UNOLS_evaluation_form.$unique"; @args = ("cp", "$response_data_file", "$backupreg"); unless (system(@args) == 0 ) { print STDOUT "

Could not backup up response file, error=$?\n"; &sendmessage($error,"Could not backup up response file", "args=@args, error=$?"); print STDOUT ( "

Your responses have not been received.

\n", "With the information we have, we will try to contact you.\n"); goto END_OF_PROGRAM; } unless (chdir $workarea) { &sendmessage($error,"Could not change to workarea=$workarea", "error code=$!"); print STDOUT ( "

Your responses have not been received.

\n", "With the information we have, we will try to contact you."); goto END_OF_PROGRAM; } foreach $key (keys %param) { if ($key =~ m/name/i) { $name = $param{$key}; $name =~ s/_/ /g; } } if (defined $name) { if (length ($name) < 3) { print STDOUT ( "

The name field is not completed. Please \n", "click the \"Back\" button on your browser, enter your \n", "name, and resubmit the form. Thank you.

\n"); goto END_OF_PROGRAM; } } else { print STDOUT ( "

The name field is not defined. Please \n", "click the \"Back\" button on your browser, enter your \n", "name, and resubmit the form. Thank you.

\n"); goto END_OF_PROGRAM; } print < $name - Your UNOLS Office performance evaluation form has been successfully submitted.

NEXT1 #Add mail as backup to collections form file $mailfile="/tmp/mail_tmp.$unique"; if (open MAIL, ">$mailfile") { print MAIL ("$all_data_export\n"); close MAIL; foreach $email_address (@email_address_to_get_data) { `/bin/mail -s \"UNOLS Performance Evaluation" $email_address <$mailfile`; } unlink $mailfile; } else { &sendmessage ($error,"Could not write temporary mail file", "file=$mailfile, error=$!"); print STDOUT ("

We have not received your completed evaluation form.", "A message has been sent to the web master to look into this. Sorry ", "for the inconvenience.

\n"); goto END_OF_PROGRAM; } print STDOUT ( "

debug, writing to response data file=$response_data_file
") if $debug eq 'yes'; if (open REG, ">>$response_data_file") { print REG ("$all_data\n"); close REG; } else { &sendmessage ($error,"Could not append to response data file", "file=$response_data_file, error=$!"); print STDOUT ("

We have not received your completed evaluation form. ", "A message has been sent to the web master to look into this. Sorry ", "for the inconvenience.

\n"); goto END_OF_PROGRAM; } print STDOUT ( "

Thanks for completing the form.", '

'); END_OF_PROGRAM: print STDOUT ("


Program version: $version\n"); undef $error; undef $warning; exit;