home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / remind23.lzh / remind.4 / remind-all.csh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1991-02-24  |  2KB  |  55 lines

  1. #!/bin/csh -f
  2.  
  3. # Shell script to mail all users reminders.
  4.  
  5. # Run it AFTER MIDNIGHT so that date is correct!
  6. # On our system, we have the following in our crontab:
  7. # 05 5 * * * /usr/share/lib/remind/remind-all > /dev/null 2>&1
  8.  
  9. # Also, you MUST use the -r and -q options on REMIND, otherwise SEVERE
  10. # security hole could develop.  I recommend making this script
  11. # readable and executable only by root to minimize security problems.
  12. # DO NOT make the script setuid!
  13.  
  14. # The following line gets a list of users for systems using SUN's
  15. # NIS service:
  16. set USERS  = `ypcat passwd | awk -F: '{print $1}'`
  17.  
  18. # The following line gets a list of users by examining /etc/passwd:
  19. # set USERS = `awk -F: '{print $1}' /etc/passwd`
  20.  
  21. # If neither of the above methods works, you must come up with some
  22. # way of getting a list of users on the system
  23.  
  24. # Set the following variables as appropriate for your system
  25. set REMIND = /usr/local/bin/remind
  26. set MAIL   = /usr/ucb/mail
  27. set CMP    = /usr/bin/cmp
  28. set RM     = "/usr/bin/rm -f"
  29.  
  30. set EMPTY  = /tmp/Empty.$$
  31. set FULL   = /tmp/Full.$$
  32.  
  33. # Create the dummy empty reminder file
  34. $REMIND -rq /dev/null > $EMPTY
  35.  
  36. # Scan each user's directory for a .reminders file
  37. foreach i ($USERS)
  38.    if (-r ~$i/.reminders) then
  39.  
  40. #     echo "$i has a .reminders file."     DEBUGGING PURPOSES ONLY
  41.  
  42.       $REMIND -rq ~$i/.reminders > $FULL
  43.       $CMP -s $EMPTY $FULL
  44.       if ($status != 0) then
  45.  
  46. #        echo "Sending mail to $i"         DEBUGGING PURPOSES ONLY
  47.  
  48.          $MAIL -s "Reminders" $i < $FULL
  49.       endif
  50.       $RM $FULL
  51.    endif
  52. end
  53.  
  54. $RM $EMPTY
  55.