#! /bin/sh
# This is a shell archive.  Remove anything before this line, then feed it
# into a shell via "sh file" or similar.  To overwrite existing files,
# type "sh file -c".
# Contents:  ckngrps
# Wrapped by kent@sparky on Tue Nov 23 00:29:58 1993
PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
echo If this archive is complete, you will see the following message:
echo '          "shar: End of archive."'
if test -f 'ckngrps' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ckngrps'\"
else
  echo shar: Extracting \"'ckngrps'\" \(3007 characters\)
  sed "s/^X//" >'ckngrps' <<'END_OF_FILE'
X#!/bin/sh
X#
X#  File Name:   ckngrps.sh
X#  Purpose  :   Determine if a Newsgroups: line contains entries for
X#               other moderated groups if crossposting.
X#  Usage    :   Edit the specific declarations below. 
X#
X#        from-within-mailer | ckngrps.sh
X#
X#  This script was written in about 30 minutes.  Please be kind...  
X#  It uses the article command from the rkive package.  If anyone
X#  needs a copy, let me know and I'll send it.  You should be able 
X#  to easily hack it to use grep but article commands were quicker 
X#  for me to write... ;-)  Quickly tested on a Sun SparcStation.
X#
X#        Kent Landfield
X#        kent@sparky.sterling.com
X#
X###################################################################
X#
X# CHANGE THESE FOR YOUR SPECIFIC NEWSGROUP NEEDS
X#
X#set -x
XME=kent@sparky.sterling.com
XMYGROUP=comp.sources.misc
X
X# Location Variable declarations
X
XACTIVE=/usr/lib/news/active
XARTICLE=/usr/local/bin/article
XTMPDIR=/usr/tmp
X
X# Temp file 
X
XTMPFILE=${TMPDIR}/ckngrps.$$
X
Xcat - > ${TMPFILE}
X
X# cleanup
X
Xtrap "rm -f ${TMPFILE}; exit 0"    0 1 2 15
X
X#
X# Get the Newsgroups line from the article and
X# replace and ','s with blank spaces.
X#
X
Xset `${ARTICLE} -f "%N" ${TMPFILE} | sed "s/,/ /g"`
X
X#
X# While we have newsgroups specified...
X#
X
Xnum=0
Xnumbad=0
Xwhile [ "$1" != "" ]
Xdo
X    num=`expr ${num} + 1`
X    #
X    # if its my group then I know about it so skip past it.
X    #
X    if [ "$1" != ${MYGROUP} ]
X    then
X        #
X        # Need to determine if the other group is moderated.
X        # Deal with multiple groups with the same partial name.
X        # I'm sure that there is a better way but this was cheap
X        # and sleezy.
X        #
X        mflag=`grep "^$1" ${ACTIVE} | awk '{ 
X            if ($1 == NG) {
X                print $4
X                break
X            }
X            else {
X                printf "-"
X                continue
X            }
X         }' NG=$1 `
X
X        #
X        # if no match then skip the rest.
X        #
X
X         if [ "${mflag}" = "-" ]
X        then
X            continue
X
X        #
X        # Is it moderated ?
X        #
X         elif [ "${mflag}" = "m" ]
X        then
X            echo "WARNING: $1 is a moderated group! "
X            echo "   EDIT: $1 out of Newsgroups: line before posting!"
X            numbad=`expr ${numbad} + 1`
X        fi
X    fi
X    shift
Xdone
X
X#
X# Everybody likes totals... :-)
X#
Xecho "====="
Xcase ${num} in
X    0) echo "No Newsgroups Line encountered"
X       ;;
X    1) if [ ${numbad} -eq 1 ]; then
X        echo "Is this a posting for ${MYGROUP} ???"
X       fi
X       ;;
X    *) echo -n "Crossposting to ${num} groups, "
X       # 
X       # Correct usage of the English language never hurts... 
X       #
X           if [ ${numbad} -eq 1 ]; then
X           echo "${numbad} is moderated and should be corrected."
X       else
X            echo "${numbad} are moderated and should be corrected."
X       fi
X       ;;
Xesac
X    
X# 
X# We're history.
X#
Xecho
Xecho -n "Press Return to continue:-> "
Xread ans < /dev/tty
X
Xexit 0
END_OF_FILE
  if test 3007 -ne `wc -c <'ckngrps'`; then
    echo shar: \"'ckngrps'\" unpacked with wrong size!
  fi
  chmod +x 'ckngrps'
  # end of 'ckngrps'
fi
echo shar: End of archive.
exit 0
