home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 0 / 0001 next >
Encoding:
Internet Message Format  |  1990-12-28  |  2.0 KB

  1. From: dfs@doe.carleton.ca (David F. Skoll)
  2. Newsgroups: alt.sources
  3. Subject: REMIND-ALL
  4. Message-ID: <dfs.657994666@riker>
  5. Date: 7 Nov 90 16:17:46 GMT
  6.  
  7. For those who've been following the REMIND saga...
  8.  
  9. The following C-Shell script can be run by cron in the wee hours of the
  10. morning to mail reminders to users who create a .reminders file in their
  11. home directory.  The script should be run sometime after midnight so that
  12. the date is correct when users arrive in the morning.
  13.  
  14. David Skoll.
  15.  
  16. ------------- CUT HERE --------------
  17. #!/bin/csh -f
  18.  
  19. # Shell script to mail all users reminders.
  20.  
  21. # Run it AFTER MIDNIGHT so that date is correct!
  22. # On our system, we have the following in our crontab:
  23. # 05 5 * * * /usr/share/lib/remind/remind-all > /dev/null 2>&1
  24.  
  25. # Also, you MUST use the -r option on REMIND, otherwise SEVERE
  26. # security hole could develop.  I recommend making this script
  27. # readable and executable only by root to minimize security problems.
  28. # DO NOT make the script setuid!
  29.  
  30. # The following line gets a list of users for systems using SUN's
  31. # NIS service:
  32. set USERS  = `ypcat passwd | awk -F: '{print $1}'`
  33.  
  34. # The following line gets a list of users by examining /etc/passwd:
  35. # set USERS = `awk -F: '{print $1}' /etc/passwd`
  36.  
  37. # If neither of the above methods works, you must come up with some
  38. # way of getting a list of users on the system
  39.  
  40. # Set the following variables as appropriate for your system
  41. set REMIND = /usr/local/bin/remind
  42. set MAIL   = /usr/ucb/mail
  43. set CMP    = /usr/bin/cmp
  44. set RM     = "/usr/bin/rm -f"
  45.  
  46. set EMPTY  = /tmp/Empty.$$
  47. set FULL   = /tmp/Full.$$
  48.  
  49. # Create the dummy empty reminder file
  50. $REMIND -r /dev/null > $EMPTY
  51.  
  52. # Scan each user's directory for a .reminders file
  53. foreach i ($USERS)
  54.    if (-r ~$i/.reminders) then
  55.  
  56. #     echo "$i has a .reminders file."     DEBUGGING PURPOSES ONLY
  57.  
  58.       $REMIND -r ~$i/.reminders > $FULL
  59.       $CMP -s $EMPTY $FULL
  60.       if ($status != 0) then
  61.  
  62. #        echo "Sending mail to $i"         DEBUGGING PURPOSES ONLY
  63.  
  64.          $MAIL -s "Reminders" $i < $FULL
  65.       endif
  66.       $RM $FULL
  67.    endif
  68. end
  69.  
  70. $RM $EMPTY
  71.