home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / linux / utilities-general / mailmandelete.script~ < prev    next >
Text File  |  2005-01-21  |  1KB  |  47 lines

  1. #!/usr/bin/perl
  2. # Created by Jimmy O'Regan
  3.  
  4. ## Script to automate the deletion of spam from Mailman's admin queue,
  5. ## via screen-scraping and filling in of the required fields on the 
  6. ## administrative Web forms.  Requires a reasonable Perl installation 
  7. ## and the WWW::Mechanize module from CPAN.  WARNING:  This script will
  8. ## delete ALL of a specified Mailman mailing list's current held mail,
  9. ## so you'll want to clear any exceptions manually before running it.
  10. ##
  11. ## Discussion that produced this script can be read here:
  12. ## http://linuxgazette.net/110/tag/8.html
  13.  
  14. use warnings;
  15. use strict;
  16. use WWW::Mechanize;
  17.  
  18. ##### User-configurable variables #######################
  19. my $password = 'PASSWORD';
  20. my $url = 'URL';
  21.  
  22. # Set to non-zero to generate a troubleshooting log
  23. my $debug = 0;
  24. ##### Past this point, There Be Dragons... ##############
  25.  
  26. my ( $mech, $content, %name ) = WWW::Mechanize -> new();
  27. $mech -> get( $url );
  28. $mech -> submit_form( fields => { adminpw => $password } );
  29. $content = $mech -> content();
  30.  
  31. die "\u$&.\n" if $content =~ /no pending requests/;
  32.  
  33. for ( grep /^senderaction-/, split /[ \n"']/, $content ){
  34.     unless ( exists $name{ $_ } ){
  35.         print "Deleting $_\n";
  36.         $name{ $_ } = 3;
  37.     }
  38. }
  39.  
  40. $mech -> submit_form( fields => \%name );
  41.  
  42. if ( $debug ){
  43.     use Data::Dumper;
  44.     open Fh, ">admreqrm.log" or die "Can't open log  $!\n";
  45.     print Fh Dumper( %{ $mech->response() } );
  46. }
  47.