#!/bin/sh

origdir=`pwd`

if [ "`zlocate $USER`" = "Hidden or not logged-in" ]
#if [ -n $foo ]
        then
        sendwidget="cat "
        else
        sendwidget="zwrite $USER -s MITGAARD_CENSUS <"
fi

cd /afs/athena.mit.edu/activity/s/sca/Census/

yearthing=`date +%y`
monththing=`date +%m`
monthnum=`expr $monththing - 0 `
daything=`date +%d`

#### ESTABLISH THAT CENSUS HAS NOT BEEN TAKEN TODAY, REPORT IF IT HAS.

sampfile=$yearthing-$monththing-$daything.samp

if [ ! -r $seasondir/$sampfile ]
        then

####
#### TAKE SAMPLE
####

                blanche -m mitgaard > 98-99/Rush98/$sampfile 2> /tmp/errorfile
                if [ -n "`grep Moira /tmp/errorfile `" ]
                        then
                        eval $sendwidget /tmp/errorfile
                        rm -f 98-99/Rush98/$sampfile
                        exit 1
                fi

fi

report=`date +%y`-`date +%m`-`date +%d`.rept

if [ ! -r 98-99/Rush98/$report ] 
        then

        ####
        #### RUN DIFF / COMM ON SAMPLE and MAKE REPORT
        ####

        lastsamp=`ls -r $seasondir/*.samp | head -2 | tail -1 `

