[Mailman-Users] searching for a user in all lists

Barry Finkel b19141 at britaine.ctd.anl.gov
Wed Nov 14 16:45:09 CET 2007


Luke Daly <Luke.Daly at newcastle.edu.au> wrote:

>Is there a way i can scan all lists for an email address? the scenario
>is i need to remove a user from all our lists (theres lots of them) in
>one go. or at the least scan all lists for an email address.

I have this script that runs via a cron each hour to produce a list
of all Mailman list subscriptions:

Mailman# cat mailman_who.exec
#!/bin/csh
# shell script to extract the subscriber addresses from each list.
# 01Feb07 1102AM  Barry Finkel
# 02Feb07 0821AM  Added another "echo" line.
# 16Mar07 0940AM  Changed "destfileold" to "$destfileold".
#                 Changed "/destfile" to "/$destfile"
# 16Mar07 1026AM  Changed the format of the destination file
# 20Jul07 1028AM  Added code to detect a list with no subscribers

set destdir = /etc/mailman/list_subscribers
set destfile = list_subscriptions
set destfilenew = list_subscriptions_new
set destfileold = list_subscriptions_old

date > $destdir/$destfilenew

# We assume that everything in this directory is a listname
# subdirectory.  If this is not the case, then we have to parse the
# "ls -al" output and remove the "." and ".." entries.
#
echo "----------" >> $destdir/$destfilenew
foreach list (`ls /var/lib/mailman/lists`)
#    In the following do we want "--fullnames"?
     /usr/lib/mailman/bin/list_members -o $destdir/$list $list
     if ( -z $destdir/$list ) then
          echo "NO_SUBSCRIBERS" > $destdir/$list
     endif
     cat $destdir/$list | \
         sed "s/^/$list /" \
        >> $destdir/$destfilenew
     echo "----------" >> $destdir/$destfilenew
end

if ( ! -z $destdir/$destfilenew ) then
     mv $destdir/$destfile $destdir/$destfileold
     mv $destdir/$destfilenew $destdir/$destfile
endif
Mailman#

I use it to see to what lists a given e-mail address is subscribed.
I have not had the need to automate unsubscribes.
----------------------------------------------------------------------
Barry S. Finkel
Computing and Information Systems Division
Argonne National Laboratory          Phone:    +1 (630) 252-7277
9700 South Cass Avenue               Facsimile:+1 (630) 252-4601
Building 222, Room D209              Internet: BSFinkel at anl.gov
Argonne, IL   60439-4828             IBMMAIL:  I1004994



More information about the Mailman-Users mailing list