#!/bin/csh -f

# Watch quota of $1 to find when there may be room to send mail in $2.

set tempfile = /tmp/watchquota.$$

while (1)
  fs listquota -path ~$1 | grep WARNING > /dev/null
  if ($status) then
    echo "I have been unable to deliver to you the mail included in the\
following message from the mailer daemon because your disk quota was\
exceeded, but I set a shell script in motion to periodically retry, and\
I've just gotten through.\
" > $tempfile
    cat $2 >> $tempfile
    mail $1 <$tempfile
    rm $tempfile
    break
  else
echo quota exceeded
    sleep 1800
  endif
end
