bernie@DIALix.oz.au (Bernd Felsche) (04/26/91)
[ The reason for the cross-post is that it's not just useful ] [ software, but also has a very neat trick for shell programmers. ] If you want to find out which newsgroups are being fed a paricular site, then this simple shell script will do the job very nicely. :-) At first I thought I'd have to write a complex awk program, or even yacc/lex something up to do it, but it turned out very simple to do in the shell. I won't tell you how it works... It's a surprise! You might have to change some of the configuration variables at the start to suit your news system, but that's about it. I doubt if this will work under MS-DOS. Most sects of Unix should be fine, as long as the shell is System V.0-ish or later. Critiques, bouquets and buckets to comp.unix.shell please. Other discussion to news.admin please. --------------------------------(cut here)-------------------------------- #!/bin/sh # This is a shar archive. un-shar and enjoy # Pipe this into /bin/sh to extract files # Manifest: sysgroups if [ -f sysgroups ] ; then echo sysgroups exists. won\'t clobber else echo extracting sysgroups sed 's/^X//' >sysgroups <<'END_OF_FILE' X: X# This program will list those newsgroups which a site will X# receive accodring to the local sys entry. X# X# Copyright(C) 1991 Bernd Felsche, (bernie@DIALix.oz.au) X# DIALix Services, Perth, Western Australia. All Rights Reserved. X# X# Removal of this notice is a violation of Copyright. X# X# You may not charge anything for the software, but you may charge X# for your services to supply and maintain the software and you may X# charge for the media required to transfer this software. X# X X# this is not deliberately obfuscated. :-) it just looks that way X XNEWSLIB=/usr/lib/news XACTIVE=$NEWSLIB/active XSYSFILE=$NEWSLIB/sys XPATH=/bin:/usr/bin Xexport PATH X Xif [ $# -ne 1 ] ; then X echo "usage: `basename $0` system" 1>&2 X exit 1 Xfi X XSYSTEM=$1 XENTRY=`(sed s+:+=+g $SYSFILE ; echo "echo \\\$$SYSTEM")|sh` X Xif [ ! "$ENTRY" ] ; then X echo "`basename $0`: no entry for system $SYSTEM" 1>&2 X exit 2 Xfi X X(echo "sort $ACTIVE|while read group stuff;do\ninclude=all" X Xecho $ENTRY|sed 's+=.*$++'|tr , '\012'| Xwhile read group ; do X case $group in X all) echo "include=all";; X !all) echo "include=" ;; X !*) group=`expr $group : '!\(.*\)` X echo "case \$group in\n$group* ) include= ;;\nesac" ;; X *) echo "case \$group in\n$group* ) include=$group ;;\nesac" ;; X esac Xdone X Xecho "[ \"\$include\" ] && echo \$group\ndone") | sh X X# now that wasn't so hard, was it? END_OF_FILE if [ $? -eq 0 ] ; then bytes=`wc -c < sysgroups` if [ $bytes -eq 1369 ] ; then echo "sysgroups extracted\n" else echo "sysgroups extract size error: was 1369, now $bytes bytes\n" fi else echo "extract sysgroups failed" fi fi # END OF ARCHIVE exit Now that's not so hard is it! -- ________Bernd_Felsche__________bernie@DIALix.oz.au_____________ [ Phone: +61 9 419 2297 19 Coleman Road ] [ TZ: UTC-8 Calista, Western Australia 6167 ]