#!/bin/csh -f
# shell script to grab posts off usenet.  List of groups and assorted other
# crap is in GROUPS.  LAST_RAN is the day and time this script last ran.

# make sure everything is clean
rm citations.* *.dat

# set the news server we want to use.
setenv NNTPSERVER news.u.washington.edu

# get the articles
rm newsucknewsrc
foreach i (1 2 3 4 5 6 7 8 9)
  sed -n $i"p" groups > sucknewsrc
  /home/cloister/pricelists/bin/suck >> articles
  cat suck.tmp >> newsucknewsrc
  rm suck.tmp suck.index suck.restart suck.sorted
end
mv groups groups.old
mv newsucknewsrc groups
ls -l articles > get.log

# sort the articles
/home/cloister/pricelists/bin/sorter *.names articles

echo "grepping for citations..." >> get.log
foreach i (*.dat)
egrep '[0-9]*\.[0-9][0-9]' $i > tempfile
sed 's/[A-Za-z_0-9]+@[a-zA-Z0-9\.]+/ /' < tempfile > citations.`basename $i .dat`
end
ls -l citations* >> get.log

# fix bogus stuff like ".44 magnum"
sed 's/.44 magnum/w.44 magnum/g' < citations.jyhad > citations.temp
sed 's/.44 Magnum/w.44 magnum/g' < citations.temp > citations.jyhad
rm citations.temp
  
# clean up after ourselves.
#rm suck.index suck.sorted tempfile

# terminate this shell script
exit
