home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / news / cnews.tar / util / report < prev    next >
Text File  |  1994-09-15  |  1KB  |  71 lines

  1. #! /bin/sh
  2. # report - report a problem
  3. # report [-u] subject <details        (details must be nonempty)
  4.  
  5. # =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  6. . ${NEWSCONFIG-/etc/news/bin/config}
  7.  
  8. PATH=$NEWSCTL/bin:$NEWSBIN:$NEWSPATH ; export PATH
  9.  
  10. ctl=$NEWSCTL/report.ctl
  11.  
  12. case "$#" in
  13. 0)    echo "Usage: $0 [-u] subject" >&2 ; exit 2    ;;
  14. esac
  15.  
  16. kind=nonurgent
  17. case "$1" in
  18. -u)    kind=urgent ; shift    ;;
  19. esac
  20.  
  21. trap '' 1 2
  22. r=/tmp/rep$$
  23. status=1
  24. trap "rm -f $r ; trap 0 ; exit \$status" 0
  25. >$r
  26.  
  27. if test ! -r $ctl
  28. then
  29.     # not a whole lot we can do... but try anyway
  30.     urgentto=root
  31.     nonurgentto=root
  32.     echo >>$r
  33.     echo "No $ctl file!!!" >>$r
  34.     echo >>$r
  35. else
  36.     . $ctl
  37.     status=0
  38. fi
  39.  
  40. case "$kind" in
  41. nonurgent)    dest="$nonurgentto" ; nb=        ;;
  42. urgent)        dest="$urgentto" ; nb=' (urgent)'    ;;
  43. esac
  44. args="`echo \"$dest\" | tr ',' ' '`"
  45.  
  46. cat >>$r
  47.  
  48. if test ! -s $r
  49. then
  50.     status=0
  51.     exit
  52. fi
  53.  
  54. (
  55.     echo "To: $dest"
  56.     echo "Subject: news$nb: $1"
  57.     echo
  58.     if egrep '^~' $r >/dev/null
  59.     then
  60.         echo 'WARNING:  the lines in this message that begin with'
  61.         echo '"***~" originally began with "~".  THIS MAY BE AN'
  62.         echo 'ATTEMPT TO BREACH SECURITY ON YOUR SYSTEM.'
  63.         echo
  64.         sed '/^~/s/^/***/' $r
  65.     else
  66.         cat $r
  67.     fi
  68. ) | mail $args        # some sites might want "/usr/lib/sendmail -t" instead
  69.  
  70. # and the trap handles the exit status
  71.