home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 January
/
usenetsourcesnewsgroupsinfomagicjanuary1994.iso
/
sources
/
misc
/
volume17
/
remind
/
part04
/
remind-all.sh
< prev
next >
Wrap
Text File
|
1991-02-19
|
2KB
|
58 lines
# Shell script to mail all users reminders.
# Thanks to Bill Aten for this script.
# Run it AFTER MIDNIGHT so that date is correct!
# On our system, we have the following in our crontab:
# 02 00 * * * /usr/local/adm/remind-all >/dev/null 2>&1
# Also, you MUST use the -r and -q options on REMIND, otherwise a 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:
# USERS=`ypcat passwd | awk -F: '{print $1}'`
# The following line gets a list of users by examining /etc/passwd:
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
REMIND=/usr/local/bin/remind
MAIL=/usr/bin/mail
CMP=/bin/cmp
RM="/bin/rm -f"
EMPTY=/tmp/Empty.$$
FULL=/tmp/Full.$$
# Create the dummy empty reminder file
$REMIND -rq /dev/null > $EMPTY
# Scan each user's directory for a .reminders file
for i in $USERS
do
HOME=`grep \^$i: /etc/passwd | awk -F: '{print $6}'`
if [ -r $HOME/.reminders ]; then
# echo "$i has a .reminders file." DEBUGGING PURPOSES ONLY
$REMIND -rq $HOME/.reminders > $FULL
if `$CMP -s $EMPTY $FULL`; then
: do nothing
else
# echo "Sending mail to $i" DEBUGGING PURPOSES ONLY
$MAIL -s "Reminders" $i < $FULL
fi
$RM $FULL
fi
done
$RM $EMPTY