#!/usr/bin/perl -w #.file sciOp_2p2ServiceReport.cgi #.purpose CGI form to submit a Service Observing report (handover) #.maintenace not too many hardcoded stuff - most are defined in the # top section # #.version 2004-06-30T10:48:47 Wed fixed a typo in email header. #.history # 2005-07-04 Copied from sciOp_reportnew.cgi for modification (FSE) # perl CGI libraries use CGI; #--- definitions # a directory where web user can write temporary files $writePath="/tmp/"; # email to which the form content must be sent. \@ $allEmail="ls-imaging\@eso.org"; # email of Instrument Scientist $bossEmail="fselman\@eso.org"; # upload directory - where to put the finders # must be read-writable by world $upload_dir = "/home/sciops/sciweb/esoonly/so_reports"; # temporary file $tmpFile = "/tmp/serviceObs2p2Rep"; # which email command to use $whichMail="/usr/bin/mailx"; $sendmail = '/usr/sbin/sendmail -t'; #------------------------------------------------------------------------------ # COMMON STUFF # Used both when calling the form first time (empty) and 2d time (filled) #------------------------------------------------------------------------------ $query = new CGI; print $query->header; #-- html header print < sciOps: Service observing report submission form
SciOp

EUROPEAN SOUTHERN OBSERVATORY

SciOp

La Silla - Science Operation Department

Report Submission Form
Version: 0.1 2005-07-04 fselman - creation
END #----- $|=0; if ($query->param) { #============================================================================== # FORM RETURNED FILLED #============================================================================== # #- READ IN THE FORM VARIABLE, AND CLEAN FOR STUPID IMPUT # i/ strings trimmed to authorized lenghts, # ii/ funny chars are deleted) $whatFlag = 0; $inWhat = substr($query->param(what),0,15); $inWhat =~ s/[^0-9]//g; if ($inWhat) { $junk = 0 } else { $whatFlag = 1; print "you must select a type of report
" } if ($inWhat == 1) { $what = "2p2Service"; $type = "report_2p2Service" } if ($inWhat > 2) {print "wrong type
" ; $whatFlag = $whatFlag +1} # if ($what == "other") { $whatFlag = 0 ; $type = "OTHER"} # $otherWhat = "NNN"; # if ($what == "other") { # $otherWhat = substr($query->param(otherWhat),0,72); # $otherWhat =~ s/[^a-z0-9A-Z .\-_]//g; # # removes all that is not in that list # # $what = $otherWhat ; # } $year = substr($query->param(year),0,4); $year =~ s/[^0-9]//g; if ($year < 2000) { print "wrong year
"; $whatFlag = $whatFlag + 1} $month = substr($query->param(month),0,4); $month =~ s/[^0-9]//g; if ($month <= 0) { $whatFlag = $whatFlag + 1; print "wrong month
"} if ( $whatFlag == 0 ) { $report = $query->param(report); $report =~ s/.*[\/\\](.*)/$1/; $upload_filehandle = $query->upload(report); $reportName = "${type}_${year}-${month}.txt"; unlink("/tmp/$reportName"); open UPLOADFILE, "> ${upload_dir}/$reportName"; binmode UPLOADFILE; while ( <$upload_filehandle> ) { print UPLOADFILE; } close UPLOADFILE; unlink("$tmpFile"); open (REPDATA,">> $tmpFile"); #- write info to file print REPDATA "To: $allEmail\n"; print REPDATA "Subject: report submitted: $what $year-$month\n"; print REPDATA "Reply-to: ls-imaging\@eso.org\n"; print REPDATA "Content-type: text/plain\n\n"; print REPDATA "Dear Service Observers,\n\n"; print REPDATA "A report has just been submitted: $what $year-$month .\n\n"; print REPDATA "It is available on the repository at\n"; print REPDATA "http://www.ls.eso.org/lasilla/sciops/esoonly/so_reports/$reportName\n\n"; print REPDATA "SciOpReport\n\n"; print REPDATA "-- + -- SciOpReport - webForm----------------------------------------------\n"; print REPDATA " +E S+ La Silla - Science Operations \n"; print REPDATA " O http://www.ls.eso.org/lasilla/sciops/bin/sciOp_2p2ServiceReport.cgi\n"; print REPDATA "-- + ----------------------------------------------------------------------\n\n\n"; foreach $i (`cat $upload_dir/$reportName`) {print REPDATA $i ;} close (REPDATA); open(SENDMAILR, "|$sendmail") or die "Cannot open $sendmail: $!" ; foreach $i (`cat $tmpFile`) {print SENDMAILR $i ;} close (SENDMAILR); print <Your report has been uploaded. It is now available at http://www.ls.eso.org/lasilla/sciops/esoonly/so_reports/$reportName.

A notification is being sent to ls-imaging.

Thanks - see you next run

END


foreach $i (`cat  $upload_dir/$reportName`)
{print  $i ;}
print "
"; } else { print <There has been an error in the info you typed. Return and re-type it. END } #============================================================================== # EMPTY FORM #============================================================================== } else { # #- write the HTML page (just static stuff) # print <repository.
  • Retrieve (right click on link) the template for your report, and fill it
  • Select the type of report you want to submit:
    • Service observing handover report:
      • ServiceObserving2p2
  • Type in the year of the report:
    (YYYY)
  • Identifier:
    (MMDD (0229) service observing report)
  • Upload the filled report
  • Submit it
  • If you want to play or test the system, pls set the year to 2999. Be aware that your test will be broadcasted too. END } #-end of filled/not filled #====================================================================== # #- common stuff for the end of html page # print <

    Contact: fselman
    [ESO |LaSilla |SciOp ]
    END # --oOo--