Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!husc6!necntc!adelie!walrus!barry From: barry@walrus.UUCP Newsgroups: news.software.b Subject: Re: Resending news using history file... Message-ID: <438@walrus.Adelie.COM> Date: Wed, 28-Jan-87 23:25:46 EST Article-I.D.: walrus.438 Posted: Wed Jan 28 23:25:46 1987 Date-Received: Fri, 30-Jan-87 05:48:54 EST References: <437@walrus.Adelie.COM> Reply-To: barry@walrus.Adelie.COM (Barry A. Burke) Distribution: world Organization: Adelie Corporation, Cambridge MA (Framingham Branch) Lines: 174 Summary: Here's two solutions... In article <437@walrus.Adelie.COM> barry@walrus.Adelie.COM (Barry A. Burke) writes: > >Does anyone have a shell script that will re-que news articles using the >history file? . . . >If anyone has one of these, please send me a copy--I'll post the best >(first?) to this newsgroup (so's to avoid the inevitable multiple >posting). If I don't get one Within A Reasonable Time, I'll write one >myself (I promise ;-). I received several responses, most of which suggested that I edit the end of the history file so that what I had was a list of article ID's, then put these into an "ihave" file (/usr/spool/batch/.ihave), and then do a "sendbatch -i -c ". Using the "ihave" strategy has the benefit that the remote side will only request those files that it didn't already have, and cross-posted articles will only be transmitted once. HOWEVER, there is one BIG, BAD side effect. Culling the history file to send only article ID's will result in sending articles in *all* newsgroups received locally- even things the remote side doesn't want, or shouldn't have. Among the shouldn't have is a real gotcha- if you run ihave/sendme with any sites- the control messages for these will ALSO get sent, which results in the remote site sending you BACK loads of articles you already have (because he sees the "sendme" messages). SO- I loooked for a strategy that would easily resend ONLY those articles that had originally been destined to the site in question (my orignial need was to be able to re-send articles when the remote site dropped several days worth of news into the "bucket" due to software problems). What I came up with is the following simple Bourne shell/awk script (requeue) that walks the "log" file(s) that news creates as it receives articles (/usr/lib/news/log*). I keep the last seven days' worth of logs around (log.0-5), so I can do requeue floozle /usr/lib/news/log* to resend the last weeks' worth of stuff, or just select any desired day(s). Since the log files contain a list of sites each article was sent to, the script assures that only the proper articles are re-transmitted. I also received a C-Shell script that automates the effort of resending using the /usr/lib/news/history file. In light of the aforementioned problems, it is probably best used IFF you don't run ihave/sendme with any other sites, OR as a tool to supply an initial swamp-load for a new "leaf" node. I include both scripts for general consumption: -----Chop-Chop----------Buzz-Buzz------Oh what a relief that wuz!------- #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create: # requeue # resend # This archive created: Wed Jan 28 23:19:31 1987 export PATH; PATH=/bin:/usr/bin:$PATH echo shar: "extracting 'requeue'" '(509 characters)' if test -f 'requeue' then echo shar: "will not over-write existing file 'requeue'" else sed 's/^ X//' << \SHAR_EOF > 'requeue' X#! /bin/sh X# X# Original-Author: Barry A. Burke X# harvard!adelie!barry Xif ( test -z "$1" -o -z "$2" ) Xthen X echo "Usage: requeue " X exit 1; Xfi Xecho "Building \"ihave\" list for $1 from $2 $3 $4 $5 $6 $7 $8 ... " Xawk '$6=="sent"{for(i=8;$i!="";i++){if((name==$i)||(name","==$i)){print$5;break;}}}' name=$1 $2 $3 $4 $5 $6 $7 $8 >> /usr/spool/batch/$1.ihave Xecho "" Xecho "Done!" Xecho " Remember to run \"/usr/lib/sendbatch -c -i $1\" to send the list" Xexit 0; X SHAR_EOF if test 509 -ne "`wc -c < 'requeue'`" then echo shar: "error transmitting 'requeue'" '(should have been 509 characters)' fi chmod +x 'requeue' fi echo shar: "extracting 'resend'" '(1348 characters)' if test -f 'resend' then echo shar: "will not over-write existing file 'resend'" else sed 's/^ X//' << \SHAR_EOF > 'resend' X#! /bin/csh -f X# X# Original-Author: Tony Birnseth X# $Header: resend.csh,v 1.9 86/10/09 13:07:45 news Exp $ X# X# Resend news articles for dates given. (actually build a batch file) X# Dates must be of the form "mm/dd/yy" X# X Xset Usage = "Usage: resend date ..." X Xset HISTORY = /usr/lib/tek/news/history Xset tmp = /tmp/resend.$$ Xset batch = /tmp/batch.$$ X Xonintr done X Xif ( $#argv < 1 ) then X echo $Usage X exit 1 Xendif X X@ i = 1 Xwhile ( $i <= $#argv ) X if ( "$argv[$i]" !~ [0-9][0-9]/[0-9][0-9]/[0-9][0-9] ) then X echo "Invalid date format <$argv[$i]> must be of form mm/dd/yy" X exit 1 X endif X @ i++ Xend X X# write out an awk script Xecho "{" > $tmp X@ i = 1 Xecho -n " if ( " >> $tmp Xwhile ( 1 ) X echo -n '$2 == ' >> $tmp X echo -n '"' >> $tmp X echo -n $argv[$i] >> $tmp X echo -n '" ' >> $tmp X @ i++ X if ( $i > $#argv ) then X echo ") " >> $tmp X break X else X echo -n " || " >> $tmp Xend Xecho ' print $4 ' >> $tmp Xecho "}" >> $tmp X Xawk -f $tmp $HISTORY | sed -e 's;\.;/;g' \ X -e 's;^;/usr/spool/news/;' \ X -e '/cancelled$/d' > $batch Xset cnt = `wc $batch` Xecho "";echo Total == $cnt[1] news articles batched. X Xecho "";echo -n "Which machines? " Xset hosts = ($<) Xforeach i ( $hosts ) X if ( "$i" == "" ) break X cat $batch >> /usr/spool/batch/$i X ls -l /usr/spool/batch/$i Xend X Xdone: Xrm -f $batch Xrm -f $tmp X SHAR_EOF if test 1348 -ne "`wc -c < 'resend'`" then echo shar: "error transmitting 'resend'" '(should have been 1348 characters)' fi chmod +x 'resend' fi exit 0 # End of shell archive