home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 5.ddi / usr / bin / calendar < prev    next >
Encoding:
Text File  |  1990-12-08  |  1.0 KB  |  39 lines

  1. #!/sbin/sh
  2. #    Copyright (c) 1990 UNIX System Laboratories, Inc.
  3. #    Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T
  4. #      All Rights Reserved
  5.  
  6. #    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF
  7. #    UNIX System Laboratories, Inc.
  8. #    The copyright notice above does not evidence any
  9. #    actual or intended publication of such source code.
  10.  
  11.  
  12. #ident    "@(#)/usr/bin/calendar.sl 1.1 4.0 12/08/90 43832 AT&T-USL"
  13. #    calendar.sh - calendar command, uses /usr/lib/calprog
  14.  
  15. PATH=/usr/bin
  16. _tmp=/tmp/cal$$
  17. trap "rm -f ${_tmp} /tmp/calendar.$$; trap '' 0; exit" 0 1 2 13 15
  18. /usr/lib/calprog > ${_tmp}
  19. case $# in
  20. 0)    if [ -f calendar ]; then
  21.         egrep -f ${_tmp} calendar
  22.     else
  23.         echo $0: `pwd`/calendar not found
  24.     fi;;
  25. *)    cat /etc/passwd | \
  26.         sed 's/\([^:]*\):.*:\(.*\):[^:]*$/_dir=\2 _user=\1/' | \
  27.         while read _token; do
  28.             eval ${_token}    # evaluates _dir= and _user=
  29.             if [ -s ${_dir}/calendar ]; then
  30.                 egrep -f ${_tmp} ${_dir}/calendar 2>/dev/null \
  31.                     > /tmp/calendar.$$
  32.                 if [ -s /tmp/calendar.$$ ]; then
  33.                     mail ${_user} < /tmp/calendar.$$
  34.                 fi
  35.             fi
  36.         done;;
  37. esac
  38. exit 0
  39.