dhb@uunet.UU.NET ( comp.sources.3b1) (02/15/91)
Submitted-by: Kris A. Kugel <hico2!kak> Posting-number: Volume 1, Issue 3 Archive-name: kugel_bnchmrk/part01 #! /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 the files: # README # Makefile # newsheaders.c # collectscript # Version # This archive created: Mon Feb 11 12:14:54 1991 export PATH; PATH=/bin:$PATH echo shar: extracting "'README'" '(1424 characters)' if test -f 'README' then echo shar: will not over-write existing file "'README'" else sed 's/^ X//' << \SHAR_EOF > 'README' Xthis is the short, quick&dirty collection of article ids Xfor "B" news. X XThe method is that you "make collect" to collect whatever Xarticle ids are currently in the sample directories. XYou should run this once within every expiration period; Xextra runs are not too harmful (will use up a little extra disk space) XAt the end of the test period, you "make send" to have your Xmailer automagicly send the stuff to the collection point, Xwhere I'll pick it up and compare it. XThe biggest problem I can see is that I don't currently Xgrap the article dates, so my comparisons will be off for Xarticles at either end of the testing period. X XTo run this stuff: Xedit the Makefile, correcting the values for MYNAME, COLLECT, XMAILADDRESS, MAILER as per the instructions inside. Xuse "make collect" to run an ID collection. Xuse "make send" to mail the collected ids to the collection point. X XAlso included: X-------------- X"collectscript" is a script version of what the Makefile is running. XIt's included for your entertainment, or if you want to figure Xout how to run the collection from crontab. (if you do that, Xmake sure you don't produce a security hole!) X X"newsheaders" is a dopey program designed to make getting the Xheaders from news articles faster. It's just a fixed-length X"head" program that pre-pends the file name to each line. Xyou could probably change collectscript to use "grep" directly, Xbut I'd expect some time penalty. SHAR_EOF if test 1424 -ne "`wc -c < 'README'`" then echo shar: error transmitting "'README'" '(should have been 1424 characters)' fi fi # end of overwriting check echo shar: extracting "'Makefile'" '(1180 characters)' if test -f 'Makefile' then echo shar: will not over-write existing file "'Makefile'" else sed 's/^ X//' << \SHAR_EOF > 'Makefile' X# X# adjust the variables below to your system X# X# MYNAME: your system name X# COLLECT: where you want the temporary file. X# MAILADDRESS: where to send the accululated file X# MAILER: command (with options) to send the file X# XCC=shcc XMYNAME=hico2 XNEWSPOOL=/usr/spool/news XDIRS= unix-pc/general unix-pc/sources unix-pc/test unix-pc/uucp unix-pc/bugs XCOLLECT= /tmp/Article-Ids XMAILADDRESS= kak2 X#MAILADDRESS= uunet!tsdiag.ccur.com!hico2!kak2 X#MAILADDRESS= kak2@hico2.westmark.com XMAILER= elm -s "Article list from $(MYNAME)" XSHAR= shar -a X Xcollect: newsheaders X D=`pwd` ; \ X for newsgroup in $(DIRS) ; \ X do \ X cd $(NEWSPOOL)/$${newsgroup} ; \ X $$D/newsheaders * | \ X egrep 'Message-ID:' | \ X sed 's/^[0-9: ]*Message-ID: *//' >> $(COLLECT) ; \ X done X # X # add a timestamp X # X echo "" "`date`" >> $(COLLECT) X Xsend: X echo "" "" $(MYNAME) >> $(COLLECT) X sort -u $(COLLECT) | $(MAILER) $(MAILADDRESS) X Xnewsheaders: newsheaders.c X $(CC) $(CFLAGS) newsheaders.c -o $@ X Xshar: collect.shar X Xcollect.shar: README Makefile newsheaders.c collectscript Version X $(SHAR) README Makefile newsheaders.c collectscript Version > $@ X Xclobber: X rm -f newsheaders $(COLLECT) collect.shar SHAR_EOF if test 1180 -ne "`wc -c < 'Makefile'`" then echo shar: error transmitting "'Makefile'" '(should have been 1180 characters)' fi fi # end of overwriting check echo shar: extracting "'newsheaders.c'" '(592 characters)' if test -f 'newsheaders.c' then echo shar: will not over-write existing file "'newsheaders.c'" else sed 's/^ X//' << \SHAR_EOF > 'newsheaders.c' X/* X * stupid version; just like "head" with filenames prepended to lines X */ X#include <stdio.h> X X#define LINES 10 X#define MAXLINE 256 X Xchar *Myname = "unknown cmd"; Xint lines = LINES; X Xmain(argc, argv) X int argc; X char **argv; X{ X int i; X char line[MAXLINE]; X FILE *fp; X X Myname = argv[0]; X X while (*++argv) X { X if ( (fp = fopen( *argv, "r" )) == NULL ) X { X fprintf(stderr, "%s: cannot open \"%s\"\n", X Myname, *argv ); X break; X } X for ( i = 0; i < lines; i++ ) X { X if ( fgets(line, MAXLINE, fp ) == NULL ) X break; X printf("%s: %s", *argv, line ); X } X fclose( fp ); X } X} SHAR_EOF if test 592 -ne "`wc -c < 'newsheaders.c'`" then echo shar: error transmitting "'newsheaders.c'" '(should have been 592 characters)' fi fi # end of overwriting check echo shar: extracting "'collectscript'" '(447 characters)' if test -f 'collectscript' then echo shar: will not over-write existing file "'collectscript'" else sed 's/^ X//' << \SHAR_EOF > 'collectscript' XNEWSPOOL="/usr/spool/news" XDIRS="unix-pc/general unix-pc/sources unix-pc/test unix-pc/uucp unix-pc/bugs" XCOLLECT=/tmp/Article-Ids X X# D=`pwd` # for those who want to modify, X # use this to return to current directory X Xfor newsgroup in $DIRS Xdo X cd ${NEWSPOOL}/${newsgroup} X newsheaders * | X egrep 'Message-ID:' | sed 's/^[0-9: ]*Message-ID: *//' >> $COLLECT Xdone X X# X# add a timestamp X# Xecho "" "`date`" >> $COLLECT SHAR_EOF if test 447 -ne "`wc -c < 'collectscript'`" then echo shar: error transmitting "'collectscript'" '(should have been 447 characters)' fi fi # end of overwriting check echo shar: extracting "'Version'" '(31 characters)' if test -f 'Version' then echo shar: will not over-write existing file "'Version'" else sed 's/^ X//' << \SHAR_EOF > 'Version' XDistribution Benchmark, v. 0.0 SHAR_EOF if test 31 -ne "`wc -c < 'Version'`" then echo shar: error transmitting "'Version'" '(should have been 31 characters)' fi fi # end of overwriting check # End of shell archive exit 0