[net.news.b] Improved postnews

draper (11/15/82)

When installing netnews it seemed to me that postnews was especially weak in
user friendliness and the discussion in this group has indeed showed that I am
not alone in that view.  I did a quick upgrade in two parts:

A) an improved manual entry that explained far more clearly the things
   postnews does and told users about the $EDITOR option,
   but also suggested preparing an article in the editor before invoking
   postnews by "postnews < file"  (this allows you to take your time, and to
   research the name of the news group and the appropriate title, rather than
   having to give them without help in reply to a prompt).

B) changing the script to suppress the prompts for title etc. if the standard
   input was a file.

	I append the sources for the man entry and the script.  Unfortunately
the script uses a local program "isatty" for which I don't have a source, that
tests to see if the standard input is a tty.

				Steve Draper
				UCSD, San Diego
				ucbvax!sdcsvax!sdcsla!draper   draper@nprdc
--------------------------------------------------------------------
.TH POSTNEWS 1
.UC
.SH NAME
postnews \- submit news articles
.SH SYNOPSIS
.BR postnews " [ "
.IR article " ]"
.SH DESCRIPTION
.I Postnews
is a shell script that calls
.IR inews (1)
to submit news articles to USENET.
It will prompt the user for the title of the article
(which should be a phrase suggesting the subject,
so that persons reading the news can tell if they
are interested in the article)
and for the newsgroup.
An omitted newsgroup (from hitting return)
will default to
.IR general .
.PP
After prompting for the title and newsgroup it will either:
(a) take the body of the article from the file given as argument, or
(b) if EDITOR is set in the environment it will put you in that editor so that
you can type the article in peace, and post it when you exit the editor; or
(c) print a prompt and take all you type as the body up to a <ctrl> D.
.PP
An even more comfortable way to use it is to prepare a file with the article
in, and with its title on the first line, and the newsgroup(s) on the second.
Then you can post the article after getting it in good shape by
"postnews\ <\ file".
.PP
.I general
is subscribed to by everyone on the local machine.
Other possible newsgroups include, but are not limited to,
.IR btl.general ,
which is read by all users at all Bell Labs sites on USENET,
.IR net.general ,
which is read by all users at all sites on USENET,
and
.IR net.news ,
which is read by users interested in the network news on all sites.
There is often a local set of newsgroups, such as
.IR sdnet.general ,
that circulate within a local set of machines.
(In this case,
.I sdnet
newsgroups circulate among machines at the
University of California at San Diego.)
.ig
.PP
After entering the title and newsgroup,
the user should type the body of the article.
To end the article, type control D at the beginning of a line.
If the environment variable EDITOR is set to the pathname of
an editor, the user will be placed in that editor instead of
typing in the article by hand.
Optionally, the article
will be read from the specified
.IR filename .
..
.PP
For more sophisticated uses, such as specifying an expiration date,
see
.IR inews (1).
.SH FILES
.PD 0
.SH "SEE ALSO"
inews(1),
readnews(1),
checknews(1),
Mail(1),
expire(8),
mail(1),
msgs(1),
recnews(8),
sendnews(8),
uucp(1),
uurec(8)
-------------------------------------------------------------------------
: '@(#) postnews.v7	2.3	4/18/82'
if [ $# -gt 1 ]; then
	echo "$0: Too many args"
	exit 1
fi
if [ $# -eq 1 -a ! -r "$1" ]; then
	echo "$0: Can't read $1"
	exit 1
fi
x=`/csl/bin/isatty`
if  [ $x -eq 1 ] ; then echo -n "Title: ";fi
read title
if  [ $x -eq 1 ] ; then echo -n "Newsgroups (general): "; fi
read ng
if [ x$ng = x ]; then
	ng=general
fi
case $# in
0)
	if [ $x -eq 0 ]
	then inews -t "$title" -n $ng
	else
		if [ x$EDITOR = x ]
		then
			echo "Type news, end with control D"
			inews -t "$title" -n $ng
		else
			t=/tmp/pn$$
			trap "rm -f $t; exit" 0 1 2
			$EDITOR $t
			inews -t "$title" -n $ng <$t &
		fi
	fi
	;;
1)
	inews -t "$title" -n $ng < $1 &
	;;
esac