home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / c / cops_104.zip / cops_104 / extra_src / mail.chk < prev    next >
Text File  |  1992-03-10  |  1KB  |  50 lines

  1. :
  2. #  mail.chk -- COPS-driveable shell script to check for problems in
  3. #              the mail spool directory.
  4. #
  5. #  This script uses awk(1) to find all files in the mail spool
  6. #  directory with improper names, permission, or ownership.  If
  7. #  it finds no bad files, it exits silently.
  8. #
  9. #  Installation: Make sure that the MAILDIR variable is set to your
  10. #  mail spool directory (/var/spool/mail or /usr/spool/mail) and
  11. #  that the executables (AWK, CAT, LS and RM) are named correctly.
  12. #
  13. #  History:
  14. #  11/08/91  Prentiss Riddle (riddle@rice.edu): Original version.
  15. #
  16. AWK=/bin/awk
  17. CAT=/bin/cat
  18. LS=/bin/ls
  19. RM=/bin/rm
  20. MAILDIR=/var/spool/mail
  21. #
  22. PROG="/usr/tmp/mchk.p$$"
  23. TEMP="/usr/tmp/mchk.t$$"
  24. #
  25. umask 077
  26. #
  27. # Unpack the awk script from a "hereis".
  28. # The script reports files with bad permissions or where filename !=
  29. # owner's userid.
  30. $RM -f $PROG
  31. cat <<'EndOfProg' >$PROG
  32. $1 == "total"                                   { next }
  33. $9 == "." || $9 == ".." || $9 == "lost+found"   { next }
  34. $1 != "-rw-------" || $3 != $9                  { print $0 }
  35. EndOfProg
  36. #
  37. # Pipe long ls through the awk script.  Save the output and print it
  38. # with a heading if it's non-null.
  39. cd "$MAILDIR"
  40. $RM -f $TEMP
  41. $LS -lag | $AWK -f $PROG >$TEMP
  42. if [ -s $TEMP ] ; then
  43.         echo 'Warning: problem files in '"$MAILDIR"':'
  44.         $CAT $TEMP
  45. fi
  46. #
  47. # Clean up.
  48. $RM -f $TEMP $PROG
  49. exit 0
  50.