diff --git a/tools/showbouncers b/tools/showbouncers new file mode 100755 index 0000000000000000000000000000000000000000..b59e03531c1cbc664f3dc1907d668e1706c6607e --- /dev/null +++ b/tools/showbouncers @@ -0,0 +1,38 @@ +#!/usr/bin/perl -w +# showbouncers - for a given domain and bounce code, list the subscribers +# NOTE: this script requires the current user has read access to the db +# Matt Taggart <taggart@riseup.net> 2019-09 + +my $listsql=q(mysql -N --batch --database=sympa --execute "select user_subscriber, bounce_subscriber from subscriber_table WHERE bounce_subscriber <> 'NULL'"); + +if ( ! $ARGV[0] ) { + print "usage: showbouncers <domain> <code>\n"; + exit 1; +} +my $targetdom = $ARGV[0]; +my $targetcode = $ARGV[1]; + +open(LISTDUMP, "$listsql|") or die "cannot get dump of address+bounce pairs from database\n"; + +while (<LISTDUMP>) { + chomp; + # match sane address and list + m/^<?(.*\@(.*?))>?\s*\t(.*) (.*) (.*) (.*)$/; + my $address=$1; + my $domain=$2; + my $firstbounce=$3; + my $lastbounce=$4; + my $bouncescore=$5; + my $bouncecode=$6; + + #print "$address $domain $firstbounce $lastbounce $bouncescore $bouncecode\n"; + + if ( ($domain eq $targetdom ) && ( $bouncecode eq $targetcode ) ) { + $subscribers{$address}=1; + } +} + +# sort by number of lists subscribed +foreach $address ( sort keys %subscribers) { + print $address, "\n"; +}