home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3065 / xkal-automail < prev   
Encoding:
Text File  |  1991-03-15  |  906 b   |  36 lines

  1. #!/bin/sh 
  2. #
  3. #    xkal-automail : Schedules an at job for the time given as
  4. #        argument. The job will basically do what xkal-mail
  5. #        does, namely mail the day's appointments if there are
  6. #        any non-zero-level ones. The job reschedules itself
  7. #        for the next day.
  8. #
  9. #    Note that the first automatic mailing will be "tomorrow" at
  10. #    the given time, not today, even it could be.
  11. #
  12. #    George Ferguson, ferguson@cs.rochester.edu, 19 Feb 1991.
  13. #
  14.  
  15. xkal=xkal
  16. mailer=Mail
  17. tmp=/tmp/xkal-automail$USER
  18.  
  19. case $# in
  20.     1) when=$1 ; rec=${USER:?} ;;
  21.     2) when=$1 ; rec=$2 ;;
  22.     *) echo 'usage: xkal-automail when [recipient]' 1>&2; exit 1
  23. esac
  24.  
  25. at -s $when tomorrow >/dev/null 2>&1 <<END_OF_SCRIPT
  26. trap "rm -f $tmp; exit 1" 1 2 3 15
  27. if $xkal -listOnly -exitUsesLevels -date +1d >$tmp
  28. then
  29.     :
  30. else
  31.     $mailer -s "Reminders from xkal for \`head -1 $tmp\`" $rec <$tmp
  32. fi
  33. rm -f $tmp
  34. xkal-automail $when $rec
  35. END_OF_SCRIPT
  36.