🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nn
Article #4161

Re: mail-alias-expander for nn

#4161
From: Jozsef Ferincz
Date: Tue, 11 May 1993 13:55
126 lines
4482 bytes
Hi, 

Here is a new mail-alias-extender for nn. This is for people, they
don't have ~/.mailrc (like nnalias need it). The aliases - if any -
in elm will be also checked.

Regards,
  Jozsef

aliasexp:
>-----------CUT HERE-----------CUT HERE-----------CUT HERE-----------<
#!/bin/sh
#
# aliasexp - alias expander for nn
#
# usage: aliasexp file
#
# Make it executable, when saved!
#
# Put in your $HOME/.nn/init this line (without '# '):
# (if location of aliasexp: ~/bin)
# set mail-alias-expander ~/bin/aliasexp
#
# aliasexp checks as first the users on the local host, as second checks
# ~/.elm/aliases - if exist. If the word(s) in the 'To:' {first} line
# has(have) some of the '@', '%' or '!' characters, then it(they) will
# be not checked for alias, it(they) will be added without any modification
# to the list of addresses. The addresses may separated by ' ' or ','.
#
# Exit codes:  0 - normal
#              1 - parameter false
#              2 - file (arg.) does not exist
#              3 - trap
#              4 - format false
#
# (C) J. Ferincz (ferincz@chemie.fu-berlin.de), 1993

myname=`basename $0`

if [ $# -ne 1 ] ; then
  echo "usage: $myname file"
  exit 1
fi

if [ ! -f $1 ] ; then
  echo "$myname: $1 does not exist"
  exit 2
fi

tmpdir=/tmp
# if you don't have LOGNAME, set it before
tmpfile=nn.$LOGNAME.$$

# !!!!!!!!!!!!!!!
# ! CHANGE THIS !
# !!!!!!!!!!!!!!!
# localaddress=`hostname`
# my domain name is a local address for me
localaddress=`domainname`

trap 'rm -f $tmpdir/$tmpfile ; echo "$myname aborted" ; exit 3' 1 2 3 15

eval inputfile=\$1
firstline=`sed 1q $inputfile`

tmpstr=`echo $firstline | awk '{print substr($0,1,3)}'`
if [ "$tmpstr" != "To:" ] ; then
  echo "$myname: not mail format"
  exit 4
fi

tonamelist="`echo $firstline | sed -e s/To:// | sed -e 's/,/ /g'`"
if [ z"$tonamelist"z = "zz" ] ; then
  echo "$myname: not mail format"
  exit 4
fi

addresslist=""
for toname in $tonamelist ; do
  # if toname has one of the [@,%,!] characters, toname isn't an aliasname
  if [ `echo $toname | awk '{print(index($0,"@"))}'` -eq 0 ] &&
     [ `echo $toname | awk '{print(index($0,"%"))}'` -eq 0 ] &&
     [ `echo $toname | awk '{print(index($0,"!"))}'` -eq 0 ] ; then
    # check the users on the local host
    tmpstr=`finger -s "$toname" | grep "$toname" | cut -f1 -d" "`
    if [ "$tmpstr" != "$toname" ] ; then
      # toname is has not account on localhost
      # check the elm aliases, if exist
      if [ -f $HOME/.elm/aliases ] ; then
        # elm is used and some alias is defined
        address=`elm -c "$toname" | cut -f3 -d" "`
        # was toname an alias?
        if [ "$address" = "$toname" ] ; then
          # alias for toname was not found
          # toname will be leave out from the addresslist
          continue
        else
          # alias found
          addresslist="$addresslist $address"
        fi
      else
        # elm is not used or alias not defined
        # toname will be leave out from the addresslist
        continue
      fi
    else
      # toname is a user on the localhost
      addresslist="$addresslist $toname@$localaddress"
    fi
  else
    addresslist="$addresslist $toname"
  fi
done

echo "To:$addresslist" > $tmpdir/$tmpfile
tail +2 $inputfile >> $tmpdir/$tmpfile
mv -f $tmpdir/$tmpfile $inputfile

exit 0
>-----------CUT HERE-----------CUT HERE-----------CUT HERE-----------<
--
Jozsef Ferincz                  INTERNET : ferincz@chemie.fu-berlin.de
Freie Universitaet Berlin           UUCP : ferincz@fub.uucp
Institut fuer Organische Chemie      Tel.: (+49 30) 838-2677, 838-5363
Takustr. 3, D-1000 Berlin 33         Fax : (+49 30) 838-5163, 838-4248
Technical Details
Message-ID: <9VDDB08I@math.fu-berlin.de>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.nn.mbox.zip!gmd.de!ira.uka.de!math.fu-berlin.de!Bragg.Chemie.FU-Berlin.DE!ferincz
References: <8TCDBWYJ@math.fu-berlin.de>

Show Full Headers
Complete Article Headers
Message-ID: <9VDDB08I@math.fu-berlin.de>
Subject: Re: mail-alias-expander for nn
Date: Tue, 11 May 1993 13:55:25 GMT
From: ferincz@chemie.fu-berlin.de (Jozsef Ferincz)
References: <8TCDBWYJ@math.fu-berlin.de>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.nn.mbox.zip!gmd.de!ira.uka.de!math.fu-berlin.de!Bragg.Chemie.FU-Berlin.DE!ferincz
Newsgroups: news.software.nn
Sender: news@math.fu-berlin.de (Math Department)
Reply-To: ferincz@chemie.fu-berlin.de
Organization: Free University of Berlin, Dept. of Chemistry
Lines: 126