[Mailman-Users] shell script to make consolidated list from other lists?
simon at caperet.com
Fri Dec 5 10:01:02 CET 2003
04-Dec-03 at 15:43, Dennis Black (dennis.black at ualberta.ca) wrote :
> John, this works for me.
> #Synch two smaller lists with a larger list.
> #If more than two, adjust 'wk' numbers.
> /home/mailman/bin/list_members the-a-list > /tmp/abc.wk1
> /home/mailman/bin/list_members the-b-list >> /tmp/abc.wk1
> cat /tmp/abc.wk1 | tr '[A-Z]' '[a-z]' > /tmp/abc.wk2
> uniq -u /tmp/abc.wk2 > /tmp/abc.wk3
> uniq -d /tmp/abc.wk2 >> /tmp/abc.wk3
> sort -d /tmp/abc.wk3 > /tmp/abc.wk4
> /home/mailman/bin/sync_members -w=no -f /tmp/abc.wk4 the-big-list
> The '-w=no' means 'don't send the welcome message.'
> Cron the above at your desired frequency.
uniq -u means print only unique lines. uniq -d means only duplicate
lines. uniq only works well if sort is applied first. add_members /
sync_members will ignore dupes anyway (but sort then uniq might be
quicker). tr is not obligatory but I can see what you're getting at
(changing case so that everyone's emails are in lower case for both
I'd do something a bit more like (replace $prefix with path to mailman)
# get member lists into the temp file
$prefix/bin/list_members the-a-list > /tmp/abc.wk1
$prefix/bin/list_members the-b-list >> /tmp/abc.wk1
# convert everything to lower case
tr '[A-Z]' '[a-z]' < /tmp/abc.wk1 > /tmp/abc.wk2
# deduplicate from 2nd temp file and overwrite 1st temp file, to save
# counting upwards all the time; we could do this on one line and pipe
# to another pipe and so on... but separating isn't such a bad thing
sort -d /tmp/abc.wk2 | uniq > /tmp/abc.wk1
# now sync back to the list
$prefix/bin/sync_members -w=no -f /tmp/abc.wk1 the-big-list
Simon White. Internet Consultant, Linux/Windows Server Administration.
Bridging the gap between management, HR and the tech team.
More information about the Mailman-Users