home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / remind23.lzh / remind.4 / remind-all.sh < prev    next >
Text File  |  1991-02-24  |  2KB  |  58 lines

  1. # Shell script to mail all users reminders.
  2.  
  3. # Thanks to Bill Aten for this script.
  4.  
  5. # Run it AFTER MIDNIGHT so that date is correct!
  6. # On our system, we have the following in our crontab:
  7. # 02 00 * * * /usr/local/adm/remind-all >/dev/null 2>&1
  8.  
  9. # Also, you MUST use the -r and -q options on REMIND, otherwise a 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. # USERS=`ypcat passwd | awk -F: '{print $1}'`
  17.  
  18. # The following line gets a list of users by examining /etc/passwd:
  19. 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. REMIND=/usr/local/bin/remind
  26. MAIL=/usr/bin/mail
  27. CMP=/bin/cmp
  28. RM="/bin/rm -f"
  29.  
  30. EMPTY=/tmp/Empty.$$
  31. 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. for i in $USERS
  38. do
  39. HOME=`grep \^$i: /etc/passwd | awk -F: '{print $6}'`
  40.    if [ -r $HOME/.reminders ]; then
  41.  
  42. #     echo "$i has a .reminders file."     DEBUGGING PURPOSES ONLY
  43.  
  44.       $REMIND -rq $HOME/.reminders > $FULL
  45.       if `$CMP -s $EMPTY $FULL`; then
  46.          : do nothing
  47.       else
  48.  
  49. #        echo "Sending mail to $i"         DEBUGGING PURPOSES ONLY
  50.  
  51.          $MAIL -s "Reminders" $i < $FULL
  52.       fi
  53.       $RM $FULL
  54.    fi
  55. done
  56.  
  57. $RM $EMPTY
  58.