#!/bin/sh
# Post file...
#
# Scan the file(s) for To: and Newsgroup: lines; send the files to the 
# appropriate recipient(s) via mail or postnews.

for f
do	grep '^To:' $f >/tmp/To$$ \
	&& mail `sed   </tmp/To$$ \
		-e 's/^To:[ 	]//' \
		-e 's/,/\
/' \
		-e 's/\(.*\)(.*)/\1/' \
		-e 's/.*<\(.*\)>/\1/'` < $f
	SB=`grep '^Subject:' $f |sed -e 's/^Subject:[ 	]*//'`
	NG=`grep '^Newsgroup[s]*:' $f |sed -e 's/^Newsgroup[s]*:[ 	]*//'`
	if [ -n "$SB" -a -n "$NG" ];then
		/u/news/lib/inews -t "$SB" -n "$NG" < $f
	fi
#	rm -f /tmp/To$$ /tmp/Ng$$
done
