#!/bin/sh # # --------- # AiresMail # --------- # # This is a sh script to send informative mails to the user of AIRES. # It is called from AiresRunner. # # Written by S. J. Sciutto, La Plata 1996, 1997, 1998; Fermilab 1999; # La Plata 2000, 2001, 2001. # # Last modification: 12/Apr/2002. # ############################################################################### # # Setting predefinded constants. # AiresSet="${HOME}/.airesrc" if [ -f $AiresSet ] then . $AiresSet else # # .airesrc file does not exist, trying in default bin directory. # AiresSet="${HOME}/aires/current/bin/airesrc" if [ -f $AiresSet ] then . $AiresSet else # # Have no other ideas about the setting file. # echo echo Cannot find internal script file! echo exit fi fi . ${Airesbindir}/AiresSetParams # if [ -x ${Airesbindir}/AiresVersion ] then vmess="(version `${Airesbindir}/AiresVersion`)" else vmess= fi # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Going to the spool directory, so we start in a known state. # cd $spooldir # # Argument $1 selects the differents kinds of mail. # if [ "_$1" != "_" ] then # mf="__AIRES_MAIL.TMP" # # A message will be sent. Preparing the mail file. # rm -f $mf echo "" > $mf echo "" >> $mf echo Dear AIRES user, >> $mf echo "" >> $mf echo This is a message from the AIRES Runner \ System $vmess, operating >> $mf echo "at host $CurrentHost (spool ${2}):" >> $mf # # Parsing argument #9. # totsh= lastsh= retkey= if [ "_$9" != "_" ] then for i in $9; do totsh="$lastsh" lastsh="$retkey" retkey="$i" done fi # # Selecting the different mail messages. # case $1 in # -1) # Found aborted process. # echo An aborted AiresRunner process was detected >> $mf echo "(PID number $3). Restarting the AIRES Runner System." >> $mf echo "" >> $mf echo "Date: `date`" >> $mf ;; # 0) # The spool is empty. # echo No more files in spool directory $2. Stopping execution. >> $mf echo "" >> $mf echo "Date: `date`" >> $mf ;; 1) # Ending a task. # # This is an informative mail. # if [ "_$AiresInfoMails" = "_NO" -o "_$AiresInfoMails" = "_No" -o \ "_$AiresInfoMails" = "_no" ] then rm -f $mf exit fi # echo Task $5 was completed. >> $mf echo "" >> $mf echo "Date: `date`" >> $mf echo "Total number of showers: $totsh" >> $mf ;; 2) # Nonzero return code. echo "Nonzero return code while processing task $5" >> $mf echo "" >> $mf echo "Date: `date`" >> $mf echo "Message: $6 ($7). Trial number $8." >> $mf echo "Last completed shower: $lastsh" >> $mf echo "Total number of showers: $totsh" >> $mf ;; 20) # Nonzero return code from BeforeProcess. echo "Nonzero return code from BeforeProcess script." >> $mf echo "" >> $mf echo "Task: $5" >> $mf echo "Date: `date`" >> $mf ;; 21) # Nonzero return code from AfterProcess. echo "Nonzero return code from AfterProcess script." >> $mf echo "" >> $mf echo "Task: $5" >> $mf echo "Date: `date`" >> $mf echo "Message: $6 ($7). Trial number $8." >> $mf echo "Last completed shower: $lastsh" >> $mf echo "Total number of showers: $totsh" >> $mf ;; 3) # Ending a run abnormally. echo "Abnormal status message while processing task $5" >> $mf echo "" >> $mf echo "Date: `date`" >> $mf echo "Message: $6 ($7). Trial number $8." >> $mf echo "Last completed shower: $lastsh" >> $mf echo "Total number of showers: $totsh" >> $mf ;; 4) # Too many retrials to start a run. echo "Too many retrials to start a process of task $5" >> $mf echo "" >> $mf echo "Date: `date`" >> $mf echo "Message: $6 ($7). Trial number $8." >> $mf echo "Last completed shower: $lastsh" >> $mf echo "Total number of showers: $totsh" >> $mf ;; 41) # Too many retrials to resubmit a run. echo "Too many retrials to resubmit a process of task $5" >> $mf echo "" >> $mf echo "Date: `date`" >> $mf echo "Message: $6 ($7). Trial number $8." >> $mf echo "Last completed shower: $lastsh" >> $mf echo "Total number of showers: $totsh" >> $mf ;; 42) # Core file detected after a run. echo "core dump file detected after a run of task $5" >> $mf echo "" >> $mf echo "Date: `date`" >> $mf echo "Message: $6 ($7). Trial number $8." >> $mf echo "Last completed shower: $lastsh" >> $mf echo "Total number of showers: $totsh" >> $mf ;; 5) # No status file after a run. echo "No status file detected after completing a run." >> $mf ;; esac # if [ $1 -gt 0 ] then echo "" >> $mf echo "You can find additional information in the log files:" >> $mf echo " - $3" >> $mf echo " - ${logdir}/${4}" >> $mf echo " - ${logdir}/AiresRestartp.log" >> $mf fi echo "" >> $mf # # Mailing. # if [ $AIRES_MAIL ] then maildir="$AIRES_MAIL" else if [ $LOGNAME ] then maildir="$LOGNAME" elif [ $USER ] then maildir="$USER" elif [ $USERNAME ] then maildir="$USERNAME" else maildir="`logname`" fi if [ $maildir ] then if [ "$CurrentHost" != "UNKNOWN" ] then maildir="${maildir}@${CurrentHost}" fi fi fi # if [ $maildir ] then if [ "_$AiresMailer" = "_" ] then mail -s 'Message from AIRES Runner System.' $maildir < $mf else $AiresMailer -s 'Message from AIRES Runner System.' $maildir < $mf fi else echo No mail address available. No mail message sent. fi rm -f $mf fi exit # # This script file is part of the AIRES Runner System; # AIRES 2.8.4a distribution. # # xxx 0 Tue Dec 12 16:28:05 ART 2006