#! /bin/sh
# Acts exactly like News 2.10 sendbatch, but uses stuff in sys directory
# rather than a sys file.  See sendbatch(8).
#
# The command "sendbatch newsvax hplabs notesvax" sends batches to the
# three systems listed.
#
#  $LIBDIR/sys/newsvax.seq   -- sequencer for newsvax
#  $LIBDIR/sys/newsvax.out   -- files to send to newsvax, in notesrc(5) format
#  $LIBDIR/sys/newsvax.cmd   -- command used to send batches to newsvax,
#				  if missing, sendbatch uses:
#				   "uux - -r -z newsvax!rnews"

LIBDIR=__LIBDIR__
TMPFILE=__TMPDIR__/nfbatch$$
RMTDIR=$LIBDIR/sys

for rmt in $*
do
	while true
	do
		$LIBDIR/newsoutput -t $rmt -f $RMTDIR/$rmt.out -s 50000 >$TMPFILE
		if __TEST__ $? -ne 0 -o ! -s $TMPFILE; then
			break
		fi
		if __TEST__ -s $RMTDIR/$rmt.cmd; then
			/bin/sh $RMTDIR/$rmt.cmd <$TMPFILE
		else
			uux - -r -z $rmt!rnews <$TMPFILE
		fi
	done
done
rm -f $TMPFILE
