Aucbarpa.1183
net.sources
utzoo!decvax!ucbvax!ARPAVAX:usenet
Tue Apr 20 19:52:02 1982
misc/sendnewsmail
>From cbosg!ucbvax!decvax!ittvax!swatt Thu Mar 25 07:06:53 1982
Date: Wed Mar 24 20:29:56 1982
From: cbosg!ucbvax!decvax!ittvax!swatt
Subject: sendnewsmail script
Via: cbosgd.uucp (V3.73 [1/5/82]); 25-Mar-82 07:06:53-EST (Thu)
Mail-From: cbosg received by cbosgd at 25-Mar-82 07:06:51-EST (Thu)
To: cbosgd!mark
Status: R


Mark:

I find the following handy as a mail interface to news; you don't have
to remake the aliases database everytime a new newsgroup gets formed.

       - Alan
=======================================================================
#! /bin/sh
: '/*********************************************************************
  program:     sendnewsmail
  description: Send news items from mail
  programmer:  Alan S. Watt
               (ittvax!swatt)

  Sccsid=@W@

  usage:
       Not invoked by user: called as program mail alias
       News item title and newsgroup(s) are specified on the
       mail subject line by:

       Subj: <NEWS ITEM TITLE> : <NEWSGROUP> ...

       Several (blank separated) newsgroups may be specified;
       the news article will be submitted to each.  There is
       no way to embed a colon character in the title, so there
       can only be one colon on the subject line.

  arguments:
       None

  notes:
       To install this, put it someplace safe from system updates
       (I use /usr/lib/news), and put an alias in the system
       mail alias file (/usr/lib/aliases) that names this program
       as the alias for the use "news":

               news:"|/usr/lib/news/sendnewsmail"

  history:
       11/11/81        original version
       11/19/81        fixed to properly handle default newsgroup
       03/13/82        changes to work with "B" netnews
       03/35/82        Modest documentation changes
  *********************************************************************/'

PROGRAM_NAME='sendnewsmail'
VERSION_NUMBER='@I@'
TOOL_LOG='/usr/advanced/logs/testlog'
USAGE='mail news'


: 'mail alias program to send news items through mail(1)'
: 'need to get newsgroup and title from subject line'

tempf=/tmp/news$$.tmp
errorf=/tmp/news$$.err

: 'copy standard input to a temporary file'
cat >$tempf

: 'read the message and grab title and newsgroups from the
  Subject line. Grab the sender from the From line.
  Header ends on first blank line (/^$/).
 '
eval `sed -n '
/^Subj/ {
       s/^Subj[^ :]*[ :] *\([^:]*\):\(.*\)/title="\1";newsgroup="\2"/p
       s/^Subj[^ :]*[ :] *\([^:]*\)$/title="\1"/p
}
/^From/ {
       s/^[fF]rom[: ] *\([^ ]*\).*/sender="\1"/p
}
/^$/    {
       b done
}
: done
' $tempf`

: 'default newsgroup to "general" if unspecified'
case $newsgroup in
'')     newsgroup=general ;;
esac

: 'make up something if the title unspecified'
case $title in
'')     title="News from mail" ;;
esac

: 'Submit the article to news'
if sed "1,/^$/d" $tempf | inews -t "$title" -n $newsgroup >$errorf 2>&1
then
       : 'OK exit, do nothing'
else
       : 'On errors, return article together with error messages to user'
       : 'Change this line if your mailer does not have a -s flag'
       mail -s 'Rejected News Article' $sender <<!EOF TEXT -F `CAT YOU </PRE : $TEMPF FOR CLEAN UP FI SUBMITTED NOT COULD ACCEPTED WAS: REASONS: OF !EOF NEWS $TEMPF` ARTICLE $ERRORF` BE $ERRORF RM THE>
<HR>
This Usenet Oldnews Archive
article may be copied and distributed freely, provided:
<P>
1. There is no money collected for the text(s) of the articles.
<BR>
2. The following notice remains appended to each copy:
<P>
<EM>The Usenet Oldnews Archive: Compilation Copyright&copy 1981, 1996
<BR> Bruce Jones, Henry Spencer, David Wiseman.</EM>
<P>
<HR>
Goto <A HREF="82.04.20_ucbarpa.1184_net.sources.html">NEXT</A> article in NET.sources Newsgroup
<BR>Return to <A HREF="NET.sources-index.html">NET.sources index</A>
<BR>Return to the
       <A HREF="../index.html">Usenet Oldnews Archive index</A>
</HTML>

-----------------------------------------------------------------
gopher://quux.org/ conversion by John Goerzen <[email protected]>
of http://communication.ucsd.edu/A-News/


This Usenet Oldnews Archive
article may be copied and distributed freely, provided:

1. There is no money collected for the text(s) of the articles.

2. The following notice remains appended to each copy:

The Usenet Oldnews Archive: Compilation Copyright (C) 1981, 1996
Bruce Jones, Henry Spencer, David Wiseman.