home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / osr5 / sco / scripts / admin / news / miss_art < prev    next >
Encoding:
Text File  |  1997-08-26  |  2.1 KB  |  93 lines

  1. :
  2. # @(#) miss_art.sh 1.0 93/01/22
  3. # 93/01/22 john h. dubois iii (john@armory.com)
  4.  
  5. while getopts h opt; do
  6.     case $opt in
  7.     h) echo \
  8. "Usage: $0 newsgroup-name
  9. $0 reports how many news articles in the given newsgroup are
  10. unreferenced and how many referenced articles are missing."
  11.     exit;;
  12.     esac
  13. done
  14.  
  15. if [ $# -eq 0 ]; then
  16.     echo "Usage: $0 [-h] newsgroup-name"
  17.     exit
  18. fi
  19.  
  20. cd /usr/spool/news/`echo $1 | tr . /` || exit
  21.  
  22. for article in *
  23. do
  24.     echo "$article"
  25. done | awk '
  26. {
  27.     NumArt++
  28.     article = $0
  29.     GoodReferences = GoodMessageID = 0
  30.     printf "%s\015",article
  31.     while (getline HeaderLine < article) {
  32.     if (HeaderLine == "") {
  33.         if (!GoodMessageID)
  34.         printf "Message-ID not found: %s\n",article > "/dev/stderr"
  35.         break
  36.     }
  37.     #Message-ID: <1568@ke4zv.UUCP>
  38.     else if (HeaderLine ~ "^Message-ID:") {
  39.         NumF = split(HeaderLine,F)
  40.         if (NumF == 2) {
  41.         if (F[2] in MessageIDs)
  42.             printf "Duplicate Message-ID in article %s\n",
  43.             article > "/dev/stderr"
  44.         MessageIDs[F[2]]++
  45.         if (GoodReferences)
  46.             break
  47.         else
  48.             GoodMessageID = 1
  49.         }
  50.         else {
  51.         printf "Bad Message-ID in article %s:\n%s\n",
  52.         article,HeaderLine > "/dev/stderr"
  53.         break
  54.         }
  55.     }
  56.     #References: <66927@iuvax.cs.indiana.edu> <90298.143116FQV@psuvm.psu.edu> <1990Oct29.213028.18754@kodak.kodak.com> <14280@smoke.brl.mil>
  57.     else if (HeaderLine ~ "^References:") {
  58.         NumF = split(HeaderLine,F)
  59.         if (NumF >= 2) {
  60.         for (i = 2; i <= NumF; i++)
  61.             References[F[i]]++
  62.         if (GoodMessageID)
  63.             break
  64.         else
  65.             GoodReferences = 1
  66.         }
  67.         else {
  68.         printf "Bad References in article %s\n",article > "/dev/stderr"
  69.         break
  70.         }
  71.     }
  72.     }
  73.     close(article)
  74. }
  75.  
  76. END {
  77. #    printf "Missing articles:\n"
  78.     for (Reference in References)
  79.     if (Reference in MessageIDs)
  80.         delete MessageIDs[Reference]
  81.     else {
  82. #        printf "%3d %s\n",References[Reference],Reference
  83.         Missing++
  84.     }
  85. #    printf "Unreferenced articles:\n"
  86.     for (ID in MessageIDs) {
  87. #    printf "%3d %s\n",MessageIDs[ID],ID
  88.     Unref++
  89.     }
  90.     printf "%d found; %d missing; %d unreferenced.\n",NumArt,Missing,Unref
  91. }
  92. '
  93.