usenet@ceetm1.UUCP (Usenet Admin) (11/19/88)
I am posting this script since there has been frequent requests for some kind of a news article batching capability. If you make any improvements or find some bugs, please mail me the fixes. Other than that, you are welcome to this. (Just don't try to sell it back to me, someday!) "batchnews >/usr/spool/batch/uunet" generates a batch file for uunet that lists all files that have arrived in the past 24 hours. The "-u" gives the actual usage description. Hope this relieves somebody's admin load. #--------------------------------CUT HERE------------------------------------- #! /bin/sh # # This is a shell archive. Save this into a file, edit it # and delete all lines above this comment. Then give this # file to sh by executing the command "sh file". The files # will be extracted into the current directory owned by # you with default permissions. # # The files contained herein are: # # -rwxr-xr-- 1 usenet news 2860 Nov 18 17:40 batchnews # echo 'x - batchnews' if test -f batchnews; then echo 'shar: not overwriting batchnews'; else sed 's/^X//' << '________This_Is_The_END________' > batchnews X#! /bin/sh X# X# Creates a list of all desired articles in a for suitable for news batching X# You can redirect stdout to the actual batch file you want to create/append X# X# Modified: Fri Nov 18 17:20:06 EST 1988 X# Added -a option X# X# Created by Y. Chao 02/03/88 X# X X# X# Adjust SPOOL variable to the appropriate place XSPOOL=/usr2/spool/news X X# X# These are the default groups excluded from batching. X# If you really want to batch all groups, then leave the junk group out Xexcpts="-e /rnews/d" X# Otherwise you can use this form as the default exclusion group X# excpts="-e /rnews/d -e "/junk/d" X X# X# Do not change anything from this point on, unless you know what X# your doing. X# Xdirnames= Xmxtime= Xmntime= Xatime= XUsage="Usage: X$0 [-a #days] [-t maxdays] [+t mindays] [!xcld_names] [news_groups] X\t-a #days\tArticles that are #days old X\t-t maxdays\tArticles that are at most maxdays old X\t+t mindays\tArticles that are at least mindays old X\t!xcld_name\tExclude any files with <xcld_name> in the path name X\tnews_groups\tArticles from this news group, do not use .all suffix X\tno options\tArticles arrived within the last 24 hours XExample:\n\t $0 -t3 +t1 rec !games !anime Xfinds all articles less that 3 days but more than 1 day old from the Xrec group except for the anime and games subgroups. XWhen maxdays and mindays are 1 day apart, then that is equivalent Xto the '-a maxdays' option." X Xwhile test $# -gt 0 Xdo X case $1 in X ?|-u) #usage X echo "$Usage" X exit 0 X ;; X X -a) atime=`expr $2 + 0`; shift;; X X -a*) atime=`echo $1 | cut -c3-`;; X X !) excpts="$excpts -e /$2/d" X shift X ;; X X !*) grp=`echo $1 | cut -c2-` X excpts="$excpts -e /$grp/d" X ;; X X +t) ttime=`expr $2 + 0` X if test $? -eq 0 -a $ttime -gt 0 X then mntime=$ttime; fi X shift X ;; X X +t*) ttime=`echo $1 | cut -c3-` X ttime=`expr $ttime + 0` X if test $? -eq 0 -a $ttime -gt 0 X then mntime=$ttime; fi X ;; X X -t) ttime=`expr $2 + 0` X if test $? -eq 0 -a $ttime -gt 0 X then mxtime=$ttime; fi X shift X ;; X X -t*) ttime=`echo $1 | cut -c3-` X ttime=`expr $ttime + 0` X if test $? -eq 0 -a $ttime -gt 0 X then mxtime=$ttime; fi X ;; X X *) grp=`echo $1 | tr . /` X dirnames="$dirnames $SPOOL/$grp" X ;; X esac X shift Xdone X Xif test ! "$dirnames"; then dirnames=$SPOOL; fi X Xif test "$atime"; then X tspan="-mtime $atime" Xelse X if test "$mxtime" -a "$mntime"; then X if test $mntime -gt $mxtime; then X tmp=$mxtime; mxtime=$mntime; mntime=$tmp; fi X tmp=`expr $mxtime - $mntime` X # they are asking for the articles mxtime days old X if test $tmp -eq 1; then X tspan="-mtime $mxtime"; mxtime=; mntime=; fi X unset tmp X fi X X if test "$mxtime"; then tspan="-mtime -$mxtime"; fi X X if test "$mntime"; then X if test "$tspan"; then tspan="$tspan -a"; fi X tspan="$tspan -mtime +$mntime" X fi Xfi X Xif test ! "$tspan"; then tspan="-mtime -1"; fi X Xfind $dirnames -type f $tspan -print | sed $excpts ________This_Is_The_END________ if test `wc -l < batchnews` -ne 121; then echo 'shar: batchnews was damaged during transit (should have been 121 bytes)' fi fi ; : end of overwriting check exit 0 -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= The USENET Person at Cincinnati Electronics, Corp.; Cincinnati, Ohio UUCP: {ukma!spca6, decuac!uccba, uunet!sdrc}!cesbws!usenet VOICE: (513)-733-6370