Skip to content
Snippets Groups Projects
Commit c326fbce authored by taggart's avatar taggart
Browse files

new script to determine which lists a list of addresses are on

parent 6cafcb75
Branches
No related tags found
No related merge requests found
#!/usr/bin/perl -w
# findcommonlists - given a list of addresses find the top lists with them subscribed
# NOTE: this script requires the current user has read access to the db
# Matt Taggart <taggart@riseup.net> 2019-08
$limit=20;
$count=0;
if (!$ARGV[0]) {
print "usage: findcommonlists <file>\n";
exit;
}
$file=$ARGV[0];
$listsql='mysql -N --batch --database=sympa --execute "select list_subscriber,user_subscriber from subscriber_table, list_table where list_subscriber=list_table.name_list and list_table.status_list=\'open\'"';
open(ADDRESSES, "$file") or die "cannot open $file\n";
open(LISTDUMP, "$listsql|") or die "cannot get dump of address+list pairs from database\n";
while (<ADDRESSES>) {
chomp;
$addresses{$_}=1;
}
while (<LISTDUMP>) {
chomp;
# match list and sane address
m/^(.*)\t<?(.*\@.*?)>?\s*$/;
$list=$1;
$address=$2;
if ( exists($addresses{$address}) ) {
$found{$list}++;
}
}
foreach $list ( sort { $found{$b} <=> $found{$a} } keys %found) {
$count++;
print "$found{$list} $list\n";
if ( $count == $limit ) {last;}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment