Path: utzoo!attcan!uunet!mcvax!ukc!stl!dww From: dww@stl.stc.co.uk (David Wright) Newsgroups: news.sysadmin Subject: Moving junk articles back to their real groups Message-ID: <789@acer.stl.stc.co.uk> Date: 16 Jul 88 11:24:28 GMT Reply-To: dww@acer.UUCP (David Wright) Organization: STL,Harlow,UK. Lines: 130 A couple of people have posted questions about how to put 'junk' articles back into their real groups, and two more have described methods. Here, I use the shell script mvjunk to do it; it was received from the net in 1985 and seems to run fine with news 2.11. It 'knows' the structure of the active file, so you'll have to change it if your news system has a diferent file structure from 2.11. Here it is: ---- #! /bin/sh # @(#)mvjunk.sh (TRW Advanced Technology Facility) STA 2-Jun-1985 # # Modified 10/22/85-James M. Scardelis, SA, Warner Computer Systems # to create newsgroups locally only. # # Move news files out of junk and into their proper directories, # updating the active list and localgroups as we go. Unknown newsgroups # are created LOCALLY and the article installed. # # Be CAREFULL with that active list! Although we try to write out # buffers as quickly as possible, conflicts can occur if someone else # tries to use it at the same time this script is running! # # Strange occurences are dribbled into mvjunk-log. # # TRW DSG EDS SISD SDL ATF STA JUNK=/usr/spool/news/junk NEWSDIR=/usr/spool/news LIB=/usr/lib/news : See line 88 chmod u+wr $LIB/active cd $JUNK if /bin/test -z "`ls`" ; then exit fi chmod u+wr * for j in $JUNK/* do for group in `egrep '^Newsgroups:' $j | head -1 | \ sed 's;Newsgroups:[ ];;' | \ sed 's;,; ;g'` do l=`egrep '^Control:' $j` if /bin/test -n "$l" ; then GROUPDIR="control" group="control" else GROUPDIR=`echo $group | sed 's;\.;\/;g'` fi # Sick Lex... really sick! cd $NEWSDIR if /bin/test -d $GROUPDIR ; then cd $GROUPDIR l=`ls` if /bin/test -n "$l" ; then a=`ls | sort -r -n` for f in $a do if /bin/test -f "$f" ; then article=`echo $f "+1" | bc` break fi done else article=1 fi else mkdir $NEWSDIR/$GROUPDIR article=1 fi cd $NEWSDIR/$GROUPDIR if /bin/test ! -d "$article" ; then cp $j $NEWSDIR/$GROUPDIR/$article chmod ugo+wrx $NEWSDIR/$GROUPDIR/$article chown news $NEWSDIR/$GROUPDIR/$article chgrp news $NEWSDIR/$GROUPDIR/$article entry=`egrep "^$group " $LIB/active` if /bin/test -z "$entry" ; then echo "Distribution: local \nControl: newgroup $group" | \ /usr/lib/news/inews -h -n control -t cmsg the_date=`date` echo "Created group $group at $date" >> $LIB/mvjunk-log entry="$group 00001 00001 y" >> $LIB/localgroups fi entry="^$entry " the_date=`date` # # There should be a way of passing shell variables into awk, but since # we don't know how to do that we just hardwire it. Kludgy... no? # echo $article $entry $the_date | \ awk 'BEGIN { FS = " " } \ { if ( NF != 11 ) printf "Munged active entry: %s\n",$0 >"/usr/lib/news/mvjunk-log" ; \ if ( length($1) > 5 ) printf "Field too large: %s\n",$0 >"/usr/lib/news/mvjunk-log" ; \ if ( length($3) > 5 ) printf "Field too large: %s\n",$0 >"/usr/lib/news/mvjunk-log" ; \ if ( length($4) > 5 ) printf "Field too large: %s\n",$0 >"/usr/lib/news/mvjunk-log" ; \ printf "/%s/s;%s;",$2,$3 ; \ for ( i = 5 - length($1) ; i > 0 ; i-- ) printf "0" ; \ print $1 ";" ; \ if ( length($4) < 5 ) { \ printf "s;%s;",$4 ; \ for ( i = 5 - length($1) ; i > 0 ; i-- ) printf "0" ; \ print $4 ";" \ } \ if ( $5 != "y" && $5 != "n" ) print "s;.$;y;" } \ END { printf "w\nq\n" }' | ed - $LIB/active else echo "Hey, there's a directory called $NEWSDIR/$GROUPDIR/$article!" echo "Hey, there's a directory called $NEWSDIR/$GROUPDIR/$article!" >> $LIB/mvjunk-log fi done if /bin/test -f $NEWSDIR/$GROUPDIR/$article ; then /bin/rm -f $j # But my MOTHER lives in Hackensack! else echo "Couldn't find the article I just installed!" echo "Couldn't find the article I just installed!" >> $LIB/mvjunk-log fi done ---- -- Regards, David Wright STL, London Road, Harlow, Essex CM17 9NA, UK dww@stl.stc.co.uk...uunet!mcvax!ukc!stl!dww PSI%234237100122::DWW