#!/usr/bin/perl # #.file ces.cgi #.purpose send an set-up request for CES #.version 2005-01-13 #.history 2005-01-13 creation from susi.cgi tdall # # 2006-01-05 Adapted for new remedy server - wlsremdy.ls.eso.org jparra # 2006-03-25 remedyEmail chenge to lsremedy@kechu.ls.eso.org ebarrios #----------------------------------------------------------------------- use CGI; $query = new CGI; # a directory where web user can write $writePath="/tmp/"; # email to which the form content must be sent. # (escape \@) $suEmail="ls-360\@eso.org"; # email of Remedy $remedyEmail="lsremedy\@kechu.ls.eso.org # $remedyEmail="esoarsls\@eso.org"; # which email command to use $whichMail="/usr/bin/mailx"; $sendmail = '/usr/sbin/sendmail -t'; #--- INSTRUMENT DEFINITION: # # Instrument Scientist, this is where you want to modify things # # In this section, define the authorized values for the various # optical elements. %labelFilt = ('00', 'RED ', '01', 'BLUE'); #-- end of instrument definition #============================================================================== # FORM HANDLING print $query->header; $|=0; # FIRST CASE: we get parameters, so the form is filled: if ($query->param) { $formStep = substr($query->param(formstep),0,1); # - FORMSTEP = 1: ANALYSE AND DISPLAY THE REPORT FOR CONFIRMATION if ( $formStep == 1 ) { #- date ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = localtime(time); $thishour = (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24) [(localtime) [2]]; $thismonth = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[(localtime)[4]]; $thisday = (Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday)[(localtime)[6]]; #-- output files $suRemedy = "suRemedy_$obsName_$year$thismonth$yday_$thishour$min.txt"; $suRemedyTail = "suRemedyTail_$obsName_$year$thismonth$yday_$thishour$min.txt"; $suFile = "suEmail_$obsName_$year$thismonth$yday_$thishour$min.txt"; $suCommon = "suCommon_$obsName_$year$thismonth$yday_$thishour$min.txt"; #- remove the output file unlink("$writePath/$suRemedy"); unlink("$writePath/$suRemedyTail"); unlink("$writePath/$suFile"); unlink("$writePath/$suCommon"); #-- read the parameters in, and filter the # values returned for strange input $mobserver = substr($query->param(observer),0,32); $mprogId = substr($query->param(progId),0,10); $msuDateYr = substr($query->param(suDateYr),0,4); $msuDateYr =~ s/[^\d]/9/g; $msuDateMo = substr($query->param(suDateMo),0,2); $msuDateMo =~ s/[^\d]/9/g; $msuDateDy = substr($query->param(suDateDy),0,2); $msuDateDy =~ s/[^\d]/9/g; $mp2pp = substr($query->param(p2pp),0,10); $mwave = substr($query->param(wave),0,10); $mFilt1 = substr($query->param(filt1), 0,2); $mFilt1 =~ s/[^\d]/9/g; $comCom = substr($query->param(comCom),0,2000); $comCom =~ s/[^a-z0-9A-Z .\-_\n]//g; #--- print the output open (SUFILE,">> $writePath/$suFile"); open (SUCOMMON,">> $writePath/$suCommon"); open (SUREMEDY,">> $writePath/$suRemedy"); open (SUREMEDYTAIL,">> $writePath/$suRemedyTail"); print SUFILE "To: $suEmail \n"; # print SUFILE "CC: ls-openg\@eso.org \n"; print SUFILE "From: lasilla@eso.org\n"; print SUFILE "Subject: CES SetUp Request: $mprogId, $msuDateYr-$msuDateMo-$msuDateDy\n"; print SUFILE "Content-type: text/plain\n\n"; print SUFILE "CES\@3.60 SETUP REQUEST\n"; print SUFILE "\n"; print SUFILE "OBSERVER: $mobserver\n"; print SUFILE "PROGRAM ID: $mprogId\n"; print SUFILE "P2PP PassWd: $mp2pp\n"; print SUFILE "Set Up Date: $msuDateYr-$msuDateMo-$msuDateDy\n"; print SUREMEDY "To: $remedyEmail \n"; print SUREMEDY "Content-type: text/plain\n\n"; print SUREMEDY "#\n"; print SUREMEDY "# File exported Thu Jun 10 15:17:12 2004\n"; print SUREMEDY "#\n"; print SUREMEDY "#AR-Message-Begin Do Not Delete This Line\n"; print SUREMEDY "Schema: SetUpRequest\n"; print SUREMEDY "Server: wlsremdy.ls.eso.org\n"; print SUREMEDY "Login: setusr\n"; print SUREMEDY "Password: setusr\n"; print SUREMEDY "Action: Submit\n"; print SUREMEDY "Format: Short\n"; print SUREMEDY "\n"; print SUREMEDY " Submitter ! 2!: $USER$ \n\n"; print SUREMEDY " Telescope !536870913!: 3p6\n"; print SUREMEDY " Instrument !536870932!: CES\n"; print SUREMEDY " Month !536870920!: $msuDateMo\n"; print SUREMEDY " Year !536870917!: $msuDateYr\n"; print SUREMEDY " Beginning_of_Night !536870916!: $msuDateDy\n"; print SUREMEDY " Assigned-to ! 4!: \n"; print SUREMEDY " Observer !536870915!: $mobserver\n"; print SUREMEDY " ObsProgID ! 8!: $mprogId\n"; print SUREMEDY " Actions taken: !536870918!: \n"; print SUREMEDY " Status ! 7!: New\n"; print SUREMEDY " Team E-Mail !536870914!: ls-360\@eso.org \n"; print SUREMEDY " Telescope Email !536870997!: ls-360\@eso.org \n"; print SUREMEDY " Detailed description: !536870921!: [\$\$\n"; print SUREMEDYTAIL "$$]\n"; print SUREMEDYTAIL "#AR-Message-End Do Not Delete This Line\n"; print SUCOMMON "==============================================\n"; print SUCOMMON "Light path: \n"; print SUCOMMON " $labelFilt{$mFilt1}\n"; print SUCOMMON "Central wavelength:\n"; print SUCOMMON " $mwave\n"; print SUCOMMON "==============================================\n"; print SUCOMMON "COMMENTS:\n"; print SUCOMMON "$comCom\n"; print SUCOMMON "==============================================\n"; print SUCOMMON "created on $thisday, $thismonth, $mday, 200"; print SUCOMMON $year-100; print SUCOMMON ", $thishour:$min:$sec \$\$]\n\n"; close (SUFILE); close (SUCOMMON); close (SUREMEDY); close (SUREMEDYTAIL); #-- show request and ask for confirmation print <

Your Set-Up request is reproduced below. Remember that this form does not perform any test: double check it.

To submit it to Science Operation, press

To edit it again, press the [Back] button on your browser. END #- writes the content of output file to html output print "


\n";
       foreach $i (`tail --lines=+6  $writePath/$suFile ; cat $writePath/$suCommon`)
       {print $i ;}
       print "

\n"; # print "
\n";
#       foreach $i (`cat  $writePath/$suRemedy  $writePath/$suCommon $writePath/$suRemedyTail`)
#       {print $i ;}
#       print "

\n"; } #============================================================================== if ( $formStep == 2 ) { # # - FORMSTEP = 2: CONFIRMED REPORT - SEND IT # $suRemedy = substr($query->param(suRemedy),0,72); $suRemedy =~ s/[^a-z0-9A-Z.\-_]//g; $suFile = substr($query->param(suFile),0,72); $suFile =~ s/[^a-z0-9A-Z.\-_]//g; $suCommon = substr($query->param(suCommon),0,72); $suCommon =~ s/[^a-z0-9A-Z.\-_]//g; #- send the instruction files via email open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!" ; foreach $i (`cat $writePath/$suFile $writePath/$suCommon `) {print SENDMAIL $i ;} close (SENDMAIL); print "...email sent\n"; open(SENDREM, "|$sendmail") or die "Cannot open $sendmail: $!" ; foreach $i (`cat $writePath/$suRemedy $writePath/$suCommon $writePath/$suRemedyTail`) {print SENDREM $i ;} close (SENDREM); print "...database filled\n"; print "

Your set-up has been submitted. It is reproduced below for your convenience in case you want to print it."; #- writes the content of output file to html output print "


\n";
       foreach $i (`tail --lines=+6  $writePath/$suFile ; cat $writePath/$suCommon`)
       {print $i ;}
       print "

\n"; } #============================================================================== # WE GOT NO PARAMETER, SO WE ARE AT STEP 0: DISPLAY THE EMPTY FORM } else { print $query->startform; print < CES Set-up Form
 [ ESO ] La Silla

La Silla - Science Operation Department
SciOp
CES\@3.60 Set-Up Form


Please use the following form to submit your set-up request for CES. If your setup is special and does not follow the standard setup form, please contact your support astronomer (beeper \#03). Note that it is critical that you discuss the set-up with your support astronomer prior to submitting the form.

This set-up form has to be submitted at the latest at 07:00 local on the day you start observing. If you submit it later, it is likely that either your set-up will not be ready in time and/or that you will be waken up early in the morning.

Please note that this form is not performing any verification on the consistency of the set-up you request: be sure to check that you are not requesting wavelengths incompatible with the chosen light path. END #--page 0 table print ""; print "
"; print ""; print "
Observer"; print $query->textfield('observer'); print " First name and name \n"; print "
Prog.Id"; print $query->textfield('progId'); print " Format: 075.D-01234(A); see schedule\n"; print "
Date of Setup"; print < First night of observations. Format: YYYY-MM-DD
P2PP Password"; print $query->textfield('p2pp'); print "Required for identification
"; print "
"; #--page 1 table print ""; #--- BIMG #--page 1 table print "
"; print ""; print "

CES\@3.60

"; print "
Light path:"; print $query->popup_menu(-name=>'filt1', -Values=>['00', '01'], -labels=>\%labelFilt, -default=>'00'); print "
Central wavelength (nm):"; print $query->textfield('wave'); print "
"; #---p 2 table print <

Additional Comments:

END print $query->submit(-value=>'SUBMIT'); print $query->reset; print $query->endform; }