Alias Lister For Users
Steve Simmons
scs at lokkur.dexter.mi.us
Sat Nov 17 13:33:51 AEST 1990
At work we live and die by email, and we've got mail aliases coming
out our ears. I get regular requests to know who's on a given alias.
Our user community is pretty computer-naive, so telling them to grep
the alias file isn't real useful. In a flash of inspiration, I threw
together the following shell script. Install it as 'printalias' (or
the name of your choice) on a sendmail-based system, and it'll give
you nice listings of who is in any given alias. It's slow, but what
the hell. Check the values of ALIASES and SENDMAIL to be sure they're
right for your installation. Enjoy.
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: printalias
# Wrapped by scs at lokkur.dexter.mi.us on Fri Nov 16 21:29:22 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'printalias' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'printalias'\"
else
echo shar: Extracting \"'printalias'\" \(1117 characters\)
sed "s/^X//" >'printalias' <<'END_OF_FILE'
X:
X# Script to tear apart a sendmail alias and list the recipients.
X# Written by Steve Simmons at home. Public domain.
X#
X# $RCSfile: printalias,v $ $Revision: 1.1 $
X#
X# $Author: scs $ $Date: 90/11/16 17:03:06 $
X#
X# $State: Exp $ $Locker: $
X#
X# $Log: printalias,v $
X# Revision 1.1 90/11/16 17:03:06 scs
X# Initial revision
X#
X#
XSCRIPT=`basename $0`
XTEMP=/tmp/$$.${SCRIPT}
XALIASES=/usr/lib/aliases
XSENDMAIL=/usr/lib/sendmail
Xif [ ! -r $ALIASES ] ; then
X echo "${SCRIPT}: Sorry, I cannot find the aliases list ($ALIASES)."
X exit 1
Xfi
Xif [ ! -r $SENDMAIL ] ; then
X echo "${SCRIPT}: Sorry, I cannot find the alias processor ($SENDMAIL)."
X exit 1
Xfi
Xtrap "rm -f $TEMP ; exit" 0 1 2
Xfor ALIAS in $*
Xdo
X if grep "^$ALIAS:" $ALIASES 1>/dev/null 2>&1 ; then
X $SENDMAIL -bv $ALIAS > $TEMP
X echo "The \`$ALIAS' alias will send to:"
X exec < $TEMP
X while read NAME1 TRASH
X do
X read NAME2 TRASH
X read NAME3 TRASH
X read NAME4 TRASH
X read NAME5 TRASH
X read NAME6 TRASH
X echo " " $NAME1 $NAME2 $NAME3 $NAME4 $NAME5 $NAME6
X done | sed -e 's/\.\.\.//g'
X else
X echo "There is no such alias as \`$ALIAS'."
X fi
Xdone
END_OF_FILE
if test 1117 -ne `wc -c <'printalias'`; then
echo shar: \"'printalias'\" unpacked with wrong size!
fi
chmod +x 'printalias'
# end of 'printalias'
fi
echo shar: End of shell archive.
exit 0
--
"When your neighbour loses his job, it's a slowdown; when you lose your own
job, it's a recession; when an economist loses his job it's a depression."
-- "Six Ways To Define A Recession", The Economist, Nov. 3 1990.
More information about the Alt.sources
mailing list