Xref: utzoo alt.sources:2605 comp.mail.misc:4334 Path: utzoo!utgpu!cs.utexas.edu!ut-emx!mic From: mic@ut-emx.uucp (Mic Kaczmarczik) Newsgroups: alt.sources,comp.mail.misc Subject: Re: Alias Lister For Users Message-ID: <39929@ut-emx.uucp> Date: 19 Nov 90 04:09:10 GMT References: <1990Nov17.023351.16824@lokkur.dexter.mi.us> Followup-To: alt.sources Organization: UT Austin Computation Center, Unix/VMS Services Lines: 66 In article <1990Nov17.023351.16824@lokkur.dexter.mi.us> scs@lokkur.dexter.mi.us (Steve Simmons) posted a sendmail alias expander that used sendmail -bv to verify the alias. One advantage of using sendmail instead of parsing the alias database directly is that it works on systems where the alias file is distributed using Sun's NIS (nee Yellow Pages) network database, instead of being a file on disk. The script below uses the same idea as Steve's script (make *sendmail* figure things out), but instead uses the SMTP EXPN command and parses the server's response. Since I haven't seen too much use of the SMTP-through-a-pipe technique elsewhere (maybe for good reasons :-), here 'tis. --mic-- ------------------------------------CUT HERE----------------------------------- #! /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 'expn' <<'END_OF_FILE' X#!/bin/sh X# X# This hack runs sendmail in SMTP mode and uses the EXPN command to X# expand an address into the real address(es) that the mail will be X# delivered to. It takes advantage of sendmail's ability to read X# SMTP commands from standard input when you use the -bs flag. X# X# Usage: X# expn alias X# X# Output: X# the address(es) mail sent to ``alias'' will really go to X Xif [ -z "$1" ]; then X echo usage: `basename $0` sendmail-alias X exit 1 Xfi Xecho "expn $1 Xquit" | /usr/lib/sendmail -bs | tr -d '\015' | \ X sed -e 's/^250.*<\([^>]*\)>.*/\1/' \ X -e 's/^5[0-9][0-9].\(.*\)/\1/' \ X -e '/^[0-9][0-9][0-9] /d' | sort Xexit 0 X END_OF_FILE if test 634 -ne `wc -c <'expn'`; then echo shar: \"'expn'\" unpacked with wrong size! fi chmod +x 'expn' # end of 'expn' fi echo shar: End of shell archive. exit 0 ------------------------------------CUT HERE-----------------------------------