#!/bin/sh
#$Header: /cygdrive/h/CVSROOT/www2/246/toys/mail/spools,v 1.1 2001/01/22 17:51:23 miura Exp $
#
# spools - $BFCDj$N?M$N(Bspool$B$r8+B3$1$k(B
#
# by Miurasoft

WHO=
TIME=180
SPOOLDIR=/var/spool/mail

while [ -n "$1" ]; do
  case x$1 in
  x-sleep)
    TIME=$2;
    shift;
    ;;
  x-dir)
    SPOOLDIR=$2;
    shift;
    ;;
  *)
    WHO=$1;
    ;;
  esac
  shift;
done

if [ -z "$WHO" ]; then
  echo usage: spools [-sleep time] [-dir spooldir] whom
  exit;
fi

SPOOL=$SPOOLDIR/$WHO

PREV=0
SIZE=0
while true; do
  clear
  date
  PREV=$SIZE
  SIZE=`ls -l $SPOOL | awk '{print $4}'`
  echo $SIZE
  if [ $SIZE -lt $PREV ]; then
    echo '****************'
    echo '* !! arrive !! *'
    echo '****************'
    exit
  fi
  sleep $TIME
done
