Annotation of 43BSD/contrib/news/misc/sendnewsmail, revision 1.1.1.1

1.1       root        1: From cbosg!ucbvax!decvax!ittvax!swatt Thu Mar 25 07:06:53 1982
                      2: Date: Wed Mar 24 20:29:56 1982
                      3: From: cbosg!ucbvax!decvax!ittvax!swatt
                      4: Subject: sendnewsmail script
                      5: Via: cbosgd.uucp (V3.73 [1/5/82]); 25-Mar-82 07:06:53-EST (Thu)
                      6: Mail-From: cbosg received by cbosgd at 25-Mar-82 07:06:51-EST (Thu)
                      7: To: cbosgd!mark
                      8: Status: R
                      9: 
                     10: 
                     11: Mark:
                     12: 
                     13: I find the following handy as a mail interface to news; you don't have
                     14: to remake the aliases database everytime a new newsgroup gets formed.
                     15: 
                     16:        - Alan
                     17: =======================================================================
                     18: #! /bin/sh
                     19: : '/*********************************************************************
                     20:    program:    sendnewsmail
                     21:    description:        Send news items from mail
                     22:    programmer: Alan S. Watt
                     23:                (ittvax!swatt)
                     24:    
                     25:    Sccsid=@W@
                     26: 
                     27:    usage:
                     28:        Not invoked by user: called as program mail alias
                     29:        News item title and newsgroup(s) are specified on the
                     30:        mail subject line by:
                     31: 
                     32:        Subj: <news item title> : <newsgroup> ...
                     33: 
                     34:        Several (blank separated) newsgroups may be specified;
                     35:        the news article will be submitted to each.  There is
                     36:        no way to embed a colon character in the title, so there
                     37:        can only be one colon on the subject line.
                     38: 
                     39:    arguments:
                     40:        None
                     41:    
                     42:    notes:
                     43:        To install this, put it someplace safe from system updates
                     44:        (I use /usr/lib/news), and put an alias in the system
                     45:        mail alias file (/usr/lib/aliases) that names this program
                     46:        as the alias for the use "news":
                     47: 
                     48:                news:"|/usr/lib/news/sendnewsmail"
                     49: 
                     50:    history:
                     51:        11/11/81        original version
                     52:        11/19/81        fixed to properly handle default newsgroup
                     53:        03/13/82        changes to work with "B" netnews
                     54:        03/35/82        Modest documentation changes
                     55:    *********************************************************************/'
                     56: 
                     57: PROGRAM_NAME='sendnewsmail'
                     58: VERSION_NUMBER='@I@'
                     59: TOOL_LOG='/usr/advanced/logs/testlog'
                     60: USAGE='mail news'
                     61: 
                     62: 
                     63: : 'mail alias program to send news items through mail(1)'
                     64: : 'need to get newsgroup and title from subject line'
                     65: 
                     66: tempf=/tmp/news$$.tmp
                     67: errorf=/tmp/news$$.err
                     68: 
                     69: : 'copy standard input to a temporary file'
                     70: cat >$tempf
                     71: 
                     72: : 'read the message and grab title and newsgroups from the
                     73:    Subject line. Grab the sender from the From line.
                     74:    Header ends on first blank line (/^$/).
                     75:   '
                     76: eval `sed -n '
                     77: /^Subj/        {
                     78:        s/^Subj[^ :]*[ :] *\([^:]*\):\(.*\)/title="\1";newsgroup="\2"/p
                     79:        s/^Subj[^ :]*[ :] *\([^:]*\)$/title="\1"/p
                     80: }
                     81: /^From/ {
                     82:        s/^[fF]rom[: ] *\([^ ]*\).*/sender="\1"/p
                     83: }
                     84: /^$/   {
                     85:        b done
                     86: }
                     87: : done
                     88: ' $tempf`
                     89: 
                     90: : 'default newsgroup to "general" if unspecified'
                     91: case $newsgroup in
                     92: '')    newsgroup=general ;;
                     93: esac
                     94: 
                     95: : 'make up something if the title unspecified'
                     96: case $title in
                     97: '')    title="News from mail" ;;
                     98: esac
                     99: 
                    100: : 'Submit the article to news'
                    101: if sed "1,/^$/d" $tempf | inews -t "$title" -n $newsgroup >$errorf 2>&1
                    102: then
                    103:        : 'OK exit, do nothing'
                    104: else
                    105:        : 'On errors, return article together with error messages to user'
                    106:        : 'Change this line if your mailer does not have a -s flag'
                    107:        mail -s 'Rejected News Article' $sender <<!EOF
                    108: 
                    109: The news article you submitted could not be accepted for the reasons:
                    110: `cat $errorf`
                    111: 
                    112: The text of the article you submitted was:
                    113: `cat $tempf`
                    114: !EOF
                    115: 
                    116: fi
                    117: 
                    118: : 'clean up'
                    119: rm -f $tempf $errorf
                    120: 
                    121: 
                    122: 
                    123: 
                    124: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.