#!/bin/csh -f

#   This script will deliver mail and news with uqwk (SOUP packet).
#   A file called "reply.zip" is expected in directory $home/poll
# @(#)Send mail and news with uqwk v. 2.0 Sep 1994 josdb@xs4all.nl (Jos den Bekker)

set workdir=/tmp/uqwkrep.$$
set repfile=~/poll/reply.zip

if ( -e $repfile ) then
  if ( -d $workdir ) then
    echo ""
    echo "         ERROR! Working-directory $workdir already exists."
    echo ""
    exit 1
  endif
  mkdir $workdir
  if ( $status != 0 ) then
    echo ""
    echo "         Error! Unable to create Working-directory $workdir"
    echo ""
    exit 1
  endif
  cd $workdir
  unzip -Uqq $repfile
  if ( $status != 0 ) then
    echo ""
    echo "       An error occurred while unzipping your reply file."
    echo ""
    cd
    rm -rf $workdir
    exit 1
  endif
  uqwk -m +L -RREPLIES -H$workdir -B0 >/dev/null
  if ( $status != 0 ) then
    echo ""
    echo "       WARNING! An Error  occurred while"
    echo "       sending your mail and news."
    echo ""
    cd
    rm -rf $workdir
    exit 1
  endif
  mv $repfile $repfile.prev
else
 echo ""
 echo "          WARNING! No reply file in poll directory."
 echo ""
 exit 1
endif

cd
rm -rf $workdir
