#!/bin/sh # # Send email to the judge. # # File: hpcm_sendmail # Author: Bob Walton # Date: Thu May 4 07:38:34 EDT 2006 # # The authors have placed this program in the public # domain; they make no warranty and accept no liability # for this program. # # RCS Info (may not be true date or author): # # $Author: hc3 $ # $Date: 2006/05/04 13:47:15 $ # $RCSfile: hpcm_sendmail,v $ # $Revision: 1.7 $ case "$1" in "") ;; *) echo " cat email_file | hpcm_sendmail Sends the email in the email_file to the judge. Similar to sendmail -oi -t but adds its own \`To:' field, which should not be included in the email_ file. The mail is sent to the address in the first read- able HPCM_ADDRESS file found by searching the current directory and its ancestors, and the mail is cc'ed to the sending user account. If the HPCM_FROM file is also found in the same directory as the HPCM_ADDRESS file, the contents of HPCM_FROM are used as the from address." exit 1 ;; esac if test -x /usr/sbin/sendmail then sendmail=/usr/sbin/sendmail elif test -x /sbin/sendmail then sendmail=/sbin/sendmail elif test -x /usr/bin/sendmail then sendmail=/usr/bin/sendmail elif test -x /bin/sendmail then sendmail=/bin/sendmail elif test -x /usr/lib/sendmail then sendmail=/usr/lib/sendmail elif test -x /lib/sendmail then sendmail=/lib/sendmail else echo Cannot find sendmail program exit 1 fi # Look for home directory. # if test -r HPCM_ADDRESS then home=. elif test -r ../HPCM_ADDRESS then home=.. elif test -r ../../HPCM_ADDRESS then home=../.. elif test -r ../../../HPCM_ADDRESS then home=../../.. elif test -r ../../../../HPCM_ADDRESS then home=../../../.. else echo "ERROR: Cannot find HPCM_ADDRESS file" exit 1 fi address=`cat $home/HPCM_ADDRESS` if test -r $home/HPCM_FROM then from=`cat $home/HPCM_FROM` f=`expr "$from" : '[^<]*<\([^>]*\)>'` if test "$f" = "" then f=$from fi f="-f $f" else from="" f="" fi # Submit program file by email. # ( if test "$from" != ""; then echo From: "$from"; fi; \ echo To: "$address"; \ echo Cc: `id -un`; \ cat - ) | $sendmail -oi -t $f exit 0