🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nn
1 messages
1 total messages Started by Scott Bass Tue, 19 Apr 1994 22:47
NN alias expander
#5722
Author: Scott Bass
Date: Tue, 19 Apr 1994 22:47
236 lines
7657 bytes
I recently received the below email in response to my recent posting
"Comparing GNUS to NN":

----- included message -----

In news.software.nn you write:

|- Saved articles (folders) can be managed by elm.

Yes, I love this as well.

|- Mailed (forwarded) articles can be processed by my alias expander, so I
|  can easily forward an article to multiple recipients.

*please* tell me how I can do this?  I use elm, I wish one could just
point nn to use elm for those functions.  How does an "alias expander"
work, and where do I get one?  I'm on a generic Sun Sparc10.  Just a user.

Sorry to be a pest...

----- end included message -----

I thought I'd post what I did here rather than send private email in case
others are interested.  Also, *I am neither a Unix nor an nn guru*.  This
is merely the best way I could come up with; there may be a better way.
Another guy at my site (Chris Sherman) helped with some of the nn concepts,
but I wrote the alias expander.  Void where prohibited, your mileage may
vary, my site may be different than yours, etc.  OK, here goes (and
apologies in advance if this msg is too long):

1.  First, nn runs a script when you mail, followup, etc.  The default
script (at my site, anyway) is /usr/local/lib/nn/aux.  Find out where your
site has installed this script if you don't find it there.

2.  Copy the script to one of your directories.  FWIW, I placed mine in
~/.nn/aux .

3.  Modify the aux script.  Here's parts of my aux script:

#!/bin/sh

# Generated by nn release 6.4.16

VERSION="6.4.16"
INEWS="/usr/local/lib/nn/inews"
INEWS_DIR="/usr/local/lib/nn"
AWK="awk"
NNTP=true
ACTIVE=/usr/local/spool/nn/ACTIVE
NNTPCACHE=
LOG=/usr/local/lib/nn/Log
TMP=${TMPDIR-/usr/tmp}
DB=/usr/local/spool/nn
BIN=/usr/local/bin
LIB=/usr/local/lib/nn
AUTH=false

# ---- end of prefix

[DELETIA TO SAVE BANDWIDTH.  IF THE DELETIA MAKES IT UNCLEAR, MAIL ME AND
I'LL SEND YOU THE ENTIRE FILE]

  e*)
    # call editor to enter at line $ED_LINE of work file

    #SWB: added sed and cp commands below

    [THIS WILL ADD AN ATTRIBUTION PREFIX (>) WHEN YOU FORWARD (MAIL) AN
    ARTICLE.  THERE MAY BE A BETTER WAY, BUT I WASN'T SURE WHAT $COPY AND
    $WORK WERE USED FOR.  THIS SEEMED THE SAFEST WAY, I.E. CHANGE $WORK AND
    COPY BACK TO $COPY]
    
    if [ "$OPERATION" = "forward" ] ; then
       sed -e "${ED_LINE},\$s/^./>&/" $COPY > $WORK
    fi
    cp $WORK $COPY

    case `basename "${EDITOR-vi}"` in
    vi|emacs|emacsclient )
      # Berkeley vi display editor
      # GNU emacs disply editor
      ${EDITOR-vi} +${ED_LINE} $WORK
      ;;
    ded )
      # QMC ded display editor
      $EDITOR -l${ED_LINE} $WORK
      ;;
    uemacs )
      # micro emacs
      $EDITOR -g${ED_LINE} $WORK
      ;;
    * )
      # Unknown editor
      $EDITOR $WORK
      ;;
    esac

[DELETIA]

  case "$OPERATION" in

    reply|forward|mail)

      #SWB: added check for alias expander
      if [ -n "${ALIAS_EXPANDER}" ] ; then
        ${ALIAS_EXPANDER} $FINAL
      fi
      if ${MAILER_PIPE} ; then
        $MAILER < $FINAL
        x=$?
      else
        $MAILER $FINAL
        x=$?
      fi
      case $x in
        0) ;;
        *) echo $MAILER failed ;;
      esac
      ;;

    follow|post)
      {

      #SWB: added check for alias expander
      if [ -n "${ALIAS_EXPANDER}" ] ; then
        ${ALIAS_EXPANDER} $FINAL

[THIS ADDITIONAL CODE BELOW ALLOWS ME TO ENTER A "To:" LINE IN THE HEADERS
OF A FOLLOW-UP OR A POST TO BOTH POST AND MAIL WITH THE SAME OPERATION.
AGAIN, YMMV DEPENDING ON YOUR MAILER, NEWS POSTING AGENT, ETC., BUT IT
WORKS AT MY SITE.  NOTE THE RETURN CODE, SEE MY ALIAS EXPANDER LATER IN
THIS MSG.]

        if [ $? = 99 ] ; then
          if ${MAILER_PIPE} ; then
            $MAILER < $FINAL
            x=$?
          else
            $MAILER $FINAL
            x=$?
          fi
          case $x in
            0) ;;
            *) echo $MAILER failed ;;
          esac
        fi
      fi
      if ${POST_PIPE} ; then
        $POST < $FINAL 2>&1
        x=$?
      else
        $POST $FINAL 2>&1
        x=$?
      fi
      case $x in
        0) sleep 60 ;;
        *) echo $INEWS failed ;;
      esac
      } | sed \
                -e "/spooled for later processing/d" \
                -e "/problem has been taken care of/d" \
                -e "/mailing your article to/d" \
                -e "/being mailed to/d" \
                -e "/is moderated/d"
      ;;

[DELETIA]

4.  Create an alias expander.  FWIW, I named mine ~/.nn/checkalias.  Here's
the code (I added all the # comments in this msg, get rid of them in your
script):

#!/usr/local/bin/perl -i   # -i means edit in place

$rc = 0;

while(<>) {
   if (! $flag) {          # only process the headers
      if (/^$/) {          # once the first blank line is encountered,
         $flag = 1;        # skip the logic and just echo back the lines
      }
      elsif (/^To:/) {
         s/To://;
         chop;
                           # look in your /usr/local/bin for a variety of
                           # alias expanders.  one of them here at my site,
                           # checkalias, essentially does this command
                           # below

         $_ = `/usr/local/bin/elm -c $_ 2> /dev/null`;

                           # all this does is convert the expanded alias
                           # to the proper format for mail and news

         s/Expands to: /To: /g;
         s/\s+/ /g;
         s/,/,\n\t/g;
         s/To: /To:\t /g;
         $_ .= "\n";

         $rc = 99;
      }
   }
   print;
}

exit $rc;

Note that it exits with rc = 99 if a "To:" line was found.

5.  In your ~/.nn/init file, set these variables:

set mail-alias-expander ~/.nn/checkalias
set mail-script         ~/.nn/aux
set news-script         ~/.nn/aux


To test the alias expander, create a dummy message in nn.  In your editor,
save it somewhere else and cancel the message.  Make a copy of the message.
Run the alias expander on the copy.  Compare the two.  The expanded message
should look agreeable to your mailer.  If so, create an elm alias for
yourself and mail or forward a message from nn to yourself.  If you have a
test newsgroup at your site, post to it, adding a To: line in the header
with your alias.  It should both be posted and mailed to you.

Note that you will not see the aliases expanded within nn before the
headers are created.

I hope this helps someone, and wasn't too wasteful of bandwidth.
--

--------------------------------------------------------------------------
Scott Bass                       |  SAS Institute Inc.
Vertical Products, H1148, x6975  |  SAS Campus Drive, Cary, NC  27513-2414
sasswb@k2.unx.sas.com            |  (919) 677-8001 x6975
--------------------------------------------------------------------------
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads