Script for clear postfix queue

Posted by

wget -O postfixqclear http://www.cristofanilli.it/util/postfixqclear.txt
chmod +x postfixqclear
./postfixqclear email-adress

#!/usr/bin/perl

$REGEXP = shift || die "no email-adress given
  (regexp-style, e.g. bl.*\@yahoo.com)!";

@data = qx;
for (@data) {
  if (/^(\w+)(\*|\!)?\s/) {
    $queue_id = $1;
  }
  if($queue_id) {
    if (/$REGEXP/i) {
      $Q{$queue_id} = 1;
      $queue_id = "";
    }
  }
}

open(POSTSUPER,"|postsuper -d -") || die "couldn't open postsuper" ;

foreach (keys %Q) {
  print POSTSUPER "$_\n";
};

close(POSTSUPER);

Leave a Reply

Il tuo indirizzo email non sarĂ  pubblicato. I campi obbligatori sono contrassegnati *