#!/usr/bin/perl #------------------------------------------------------------------------------- # date_reminder - written 10/30/2002 by Kelly Cash kelly@the-clearing.org # # Purpose: Periodically scans a file containing dates and reminds user of them. # Good for birthdays, anniversaries, etc. # # Arguments: None. # Sub scripts: mail, mailx, some other mailer program # Called by: None. # Files needed: reminder_dates # # Data file format: # * Date (mm/dd/yy), then anything else you like. Currently only the first two # characters are examined- The month. # This routine only looks at the upcoming month's dates. # * Example: # 07/04/xx Holiday - Independence Day # 09/28/25 Birthday - Seymore Cray # # Notes: * Best used as a cron job so it runs whether you're logged in or not. # On Windows systems, you might put it in the startup folder. # * Modify customizable variables below to reflect your preferences and devices. # * In case this routine can't find the data file, it won't shut down- It'll # send a message to the recipient that the file's missing. # That means that if this is in the crontab, you get a message potentially # every month until the file is replaced. # * The "debug" variable is 0 by default. Positive value prints extra info. # # Revision History: # Who When What # KCash 10/30/02 Initial Implementation #------------------------------------------------------------------------------- # ---- Beginning of user customizable variables -------------------------------- $data = "/usr/home/kelly/reminder_dates"; # Location of dates file $recipient = "kelly"; # Recipient of reminders $mailer = "mailx"; # Mailer program $debug = 0; # Level of debug output. 0 is default # ---- End of user customizable variables -------------------------------------- $open_return = open(DATA,$data); if ($open_return == 1) { # Data file has been found. Good. printf "In data analysis section\n" if ($debug > 0); $cur_month = `date '+%m`; chop($cur_month); $next_month = $cur_month + 1; $next_month = 1 if ($next_month > 12); $num_events = 0; open(OUT,">./remind_temp"); while ($rec = ) { chop($rec); printf "Rec: %s\n", $rec if ($debug > 0); if (substr($rec,0,2) == $next_month) { $num_events++; printf OUT "Upcoming: %s\n", $rec; } } printf OUT "No events for next month listed in data file.\n" if ($num_events < 1); close OUT; system("$mailer -s 'Upcoming Events' $recipient <./remind_temp"); system("rm ./remind_temp"); } else { # Data file was not found. Tell the user to replace it. system("$mailer -s 'date_reminder: reminder data file not found.' $recipient