home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2 / Openstep-4.2-Intel-User.iso / usr / bin / calendar < prev    next >
Text File  |  1997-03-28  |  890b  |  37 lines

  1. PATH=/bin:/usr/bin:
  2. tmp=/tmp/cal0$$
  3. trap "rm -f $tmp /tmp/cal1$$ /tmp/cal2$$"
  4. trap exit 1 2 13 15
  5. /usr/lib/calendar >$tmp
  6. case $# in
  7. 0)
  8.     trap "rm -f $tmp ; exit" 0 1 2 13 15
  9.     if test -r calendar
  10.     then
  11.         /lib/cpp calendar | /usr/ucb/expand | egrep -f $tmp 
  12.     else
  13.         echo Calendar: Could not find calendar file in current directory
  14.     fi
  15.     ;;
  16. *)
  17.     trap "rm -f $tmp /tmp/cal1$$ /tmp/cal2$$; exit" 0 1 2 13 15
  18.     /bin/echo -n "Subject: Calendar for " > /tmp/cal1$$
  19.     date | sed -e "s/ [0-9]*:.*//" >> /tmp/cal1$$
  20.     ( cat /etc/passwd; nidump passwd . ; /usr/lib/calendar -p ) | sort -t: -u +0 -1 |    
  21.     sed '
  22.         s/\([^:]*\):.*:\(.*\):[^:]*$/y=\2 z=\1/
  23.     ' \
  24.     | while read x
  25.     do
  26.         eval $x
  27.         if test -r $y/calendar
  28.         then
  29.             (/lib/cpp $y/calendar | /usr/ucb/expand | egrep -f $tmp) 2>/dev/null > /tmp/cal2$$
  30.             if test -s /tmp/cal2$$
  31.             then
  32.                 cat /tmp/cal1$$ /tmp/cal2$$ | /bin/mail $z
  33.             fi
  34.         fi
  35.     done
  36. esac
  37.