reading sendmail alaises

Steve Holden sholden at holdenweb.com
Fri Feb 1 16:46:27 EST 2002


"David Bear" <iddwb at moroni.pp.asu.edu> wrote in message
news:m34rl2jh7m.fsf at moroni.pp.asu.edu...
> I would like a quick way to resolve sendmail aliases.  I've thought
> about reading and parsing /etc/aliases myself but thats too much
> work.  Is there some module/interface to sendmail that would allow
> something like
>
> realaddress = sendmail.resolve-alias(name)
>
> Even though I could build a dictionary from aliases, the file may
> actually be in db format -- so I'm looking for a 'sendmail' way of
> grabbing them.
>
[root at headrat tmp]# /usr/lib/sendmail -bv testalias
sholden... deliverable: mailer local, user sholden
root... deliverable: mailer local, user root

so:

#! /usr/bin/python

import os, sys, string
f = os.popen("/usr/lib/sendmail -bv %s" % string.join(sys.argv[1:], " "))
names = []
while 1:
    line = f.readline()
    if not line: break
    name = string.split(line)[0]
    names.append(name[:-3])

print names

Sorry about the 1.5isms - nothing more recent to hand :-)

regards
 Steve
--
Consulting, training, speaking: http://www.holdenweb.com/
Python Web Programming: http://pydish.holdenweb.com/pwp/








More information about the Python-list mailing list