#!/usr/bin/perl use FileHandle; use IPC::Open3; require "timelocal.pl"; @mname = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); %mnum = ("Jan", 0, "Feb", 1, "Mar", 2, "Apr", 3, "May", 4, "Jun", 5, "Jul", 6, "Aug", 7, "Sep", 8, "Oct", 9, "Nov",10, "Dec",11); $username = getpwuid($>) or die "$zero: who are you?? getpwuid($>) failed\n"; die < 0; usage: $0 datetime message... datetime can be any string containing 12 digits: 4 digits year 2 digits month 2 digits day of month 2 digits hour 2 digits minutes for example: 1998-12-30-19:30 all arguments after the first become your message text. USAGE $date = shift; $message = "@ARGV"; ($year,$mon,$mday,$hour,$min,$sec) = $date =~ /^\D*(\d{4})\D*(\d{2})\D*(\d{2})\D*(\d{2})\D*(\d{2})/ or die "What date is that? $date\nTry YYYY-MM-DD-HH:MM (or just YYYYMMDDHHMM)\n"; $time = timelocal($sec,$min,$hour,$mday,$mon-1,$year-1900); die "That time is in the past or doesn't make sense: $time\n" if $time < time; $dateformat .= "%02d:%02d %s %02d, %04d"; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($time); $pagetime = sprintf $dateformat, $hour,$min, $mname[$mon],$mday,$year+1900; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $currtime = sprintf $dateformat, $hour,$min, $mname[$mon],$mday,$year+1900; $atr = new FileHandle; $atw = new FileHandle; $ate = new FileHandle; $atpid = open3($atw, $atr, $ate, "/bin/at $pagetime"); print $atw "echo '$message' | /usr/ucb/Mail -s 'alarm set on $currtime' ${username}-beep\n"; close $atw; print <$atr>; close $atr; while(<$ate>) { next if /^commands will be executed using \S+sh$/; next if ($atjob,$atdate) = /^job (\S+) at (.+\d)\s*$/; print; } close $ate; print <