home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / remind-03.00.19.tgz / remind-03.00.19.tar / remind-03.00.19 / scripts / remind-all.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1998-02-13  |  2KB  |  55 lines

  1. #!/bin/sh
  2. # Shell script to mail all users reminders.
  3.  
  4. # This file is part of REMIND
  5. #
  6. # $Id: remind-all.sh,v 1.2 1998/02/14 03:56:27 dfs Exp $
  7. #
  8. # REMIND is Copyright (C) 1992-1998 by David F. Skoll        
  9. # This file is Copyright (C) 1990 by Bill Aten
  10.  
  11. # Thanks to Bill Aten for this script.
  12.  
  13. # Run it AFTER MIDNIGHT so that date is correct!
  14. # On our system, we have the following in our crontab:
  15. # 02 00 * * * /usr/local/adm/remind-all >/dev/null 2>&1
  16.  
  17. # This script must be run by root.  The -u option MUST be supplied
  18. # to Remind, or a severe security hole will exist.  Note that Remind
  19. # must be compiled to support the -u option for this script to work.
  20. # Also, the -r and -q options must be used.
  21.  
  22. # The following line gets a list of users for systems using SUN's
  23. # NIS service:
  24. # USERS=`ypcat passwd | awk -F: '{print $1}'`
  25.  
  26. # The following line gets a list of users by examining /etc/passwd:
  27. USERS=`awk -F: '{print $1}' /etc/passwd`
  28.  
  29. # If neither of the above methods works, you must come up with some
  30. # way of getting a list of users on the system
  31.  
  32. # Set the following variables as appropriate for your system
  33. REMIND=/usr/local/bin/remind
  34. MAIL=/usr/bin/mail
  35. RM="/bin/rm -f"
  36.  
  37. REMFILE=/tmp/RemFile.$$
  38.  
  39. # Scan each user's directory for a .reminders file
  40. for i in $USERS
  41. do
  42. HOME=`grep \^$i: /etc/passwd | awk -F: '{print $6}'`
  43.    if [ -r $HOME/.reminders ]; then
  44.  
  45. #     echo "$i has a .reminders file."     DEBUGGING PURPOSES ONLY
  46.  
  47.       $REMIND -u$i -h -r -q -iremind_all=1 $HOME/.reminders < /dev/null > $REMFILE
  48.       if [ -s $REMFILE ]; then
  49. #        echo "Sending mail to $i"         DEBUGGING PURPOSES ONLY
  50.          $MAIL -s "Reminders" $i < $REMFILE
  51.       fi
  52.       $RM $REMFILE
  53.    fi
  54. done
  55.