REMIND-ALL

David F. Skoll dfs at doe.carleton.ca
Thu Nov 8 03:17:46 AEST 1990


For those who've been following the REMIND saga...

The following C-Shell script can be run by cron in the wee hours of the
morning to mail reminders to users who create a .reminders file in their
home directory.  The script should be run sometime after midnight so that
the date is correct when users arrive in the morning.

David Skoll.

------------- CUT HERE --------------
#!/bin/csh -f

# Shell script to mail all users reminders.

# Run it AFTER MIDNIGHT so that date is correct!
# On our system, we have the following in our crontab:
# 05 5 * * * /usr/share/lib/remind/remind-all > /dev/null 2>&1

# Also, you MUST use the -r option on REMIND, otherwise SEVERE
# security hole could develop.  I recommend making this script
# readable and executable only by root to minimize security problems.
# DO NOT make the script setuid!

# The following line gets a list of users for systems using SUN's
# NIS service:
set USERS  = `ypcat passwd | awk -F: '{print $1}'`

# The following line gets a list of users by examining /etc/passwd:
# set USERS = `awk -F: '{print $1}' /etc/passwd`

# If neither of the above methods works, you must come up with some
# way of getting a list of users on the system

# Set the following variables as appropriate for your system
set REMIND = /usr/local/bin/remind
set MAIL   = /usr/ucb/mail
set CMP    = /usr/bin/cmp
set RM     = "/usr/bin/rm -f"

set EMPTY  = /tmp/Empty.$$
set FULL   = /tmp/Full.$$

# Create the dummy empty reminder file
$REMIND -r /dev/null > $EMPTY

# Scan each user's directory for a .reminders file
foreach i ($USERS)
   if (-r ~$i/.reminders) then

#     echo "$i has a .reminders file."     DEBUGGING PURPOSES ONLY

      $REMIND -r ~$i/.reminders > $FULL
      $CMP -s $EMPTY $FULL
      if ($status != 0) then

#        echo "Sending mail to $i"         DEBUGGING PURPOSES ONLY

         $MAIL -s "Reminders" $i < $FULL
      endif
      $RM $FULL
   endif
end

$RM $EMPTY



More information about the Alt.sources mailing list