qintar@agora.rain.com (Jim Seymour) (05/23/91)
I have written a shell program which scans the articles in c.b.i.p. and automatically extracts the files from them. I will include it below if anybody is interested. Now, here are a couple of caveats... First, I'm new to shell programming and so this is by no means an elegant script! If anybody has suggestions as to improving it, PLEASE let me know. I'm also interested in making a Bourne shell equivalent so that it can be used more universally. Secondly, it tends to spit out a bunch of garbage when it can't find certain files. This causes no troubles, but is kind of distressing. Here is the program. Feedback to qintar@agora.rain.com would be appreciated! ---CUT-HERE--- # Set up the variables we'll be using newsdir=/usr/spool/news/comp/binaries/ibm/pc control=$HOME/.ibmtime workdir=$HOME/tmp destdir=/var/spool/ftp/pub/ibmpc foundone=no # Go to the news directory and scan articles newer than our control file cd $workdir for i in $newsdir/* do if test -f $i && test $i -nt $control then exec < $i while read Ltype Vname Fname extra do if test $Ltype = 'Subject:' then if test ${#Vname} = '8' then Fname=${Fname%%\,*} xx=${extra##*\(part } xx=${xx%%/*} yy=${extra##*/} yy=${yy%%\)*} echo $i is $Fname, part $xx of $yy foundone=yes if test $yy = '01' then echo Unpacking $Fname uudecode < $i else cp $i $Fname.$xx fi fi break fi done fi done touch $control if test $foundone = "yes" then # Decode the multi-part postings for i in *.01 do echo Unpacking ${i%.*} cat ${i%.*}.* | sed '/^END/,/^BEGIN/d'| uudecode if test $? != "0" then echo ${i%.*} did not unpack correctly! rm ${i%.*}.zoo fi done # Check the .zoo files for errors. If none, delete the individual parts for i in *.zoo do zoo xN $i if test $? != "0" then echo $i fails verification! rm $i else rm ${i%.*}.[0-9]* fi done # List the resulting files and move them to our destination directory ls -l *.zoo cp *.zoo $destdir mv *.zoo $HOME/download else echo No new articles found! fi du $destdir exit ---CUT-HERE--- -Jim Seymour qintar@agora.rain.com ================================================================= Cipher Systems, Inc., P.O. Box 329, North Plains, OR 97133