X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fsrc%2Fexiqgrep.src;h=d900e99337a49be8709277bae1eb0d203f34aa22;hb=c29da374ab4ea587c810bdc0395443d6b6164fea;hp=da63c99809aae4af2d3e6a5745f0b911902fcabd;hpb=3634fc257bd0667daef14d72005cd87c735bbb24;p=user%2Fhenk%2Fcode%2Fexim.git diff --git a/src/src/exiqgrep.src b/src/src/exiqgrep.src index da63c9980..d900e9933 100644 --- a/src/src/exiqgrep.src +++ b/src/src/exiqgrep.src @@ -15,9 +15,10 @@ # Routine for extracting the UTC timestamp from message ID # lifted from eximstat utility -# Version 1.1 +# Version 1.2 use strict; +BEGIN { pop @INC if $INC[-1] eq '.' }; use Getopt::Std; # Have this variable point to your exim binary. @@ -43,8 +44,11 @@ if ($^O eq 'darwin') { # aka MacOS X $base = 62; }; -getopts('hf:r:y:o:s:zxlibRc',\%opt); +getopts('hf:r:y:o:s:C:zxlibRca',\%opt); +if ($ARGV[0]) { &help; exit;} if ($opt{h}) { &help; exit;} +if ($opt{a}) { $eargs = '-bp'; } +if ($opt{C} && -e $opt{C} && -f $opt{C} && -R $opt{C}) { $eargs .= ' -C '.$opt{C}; } # Read message queue output into hash &collect(); @@ -60,6 +64,7 @@ sub help() { Exim message queue display utility. -h This help message. + -C Specify which exim.conf to use. Selection criteria: -f Match sender address sender (field is "< >" wrapped) @@ -78,16 +83,17 @@ Display options: -i Message IDs only -b Brief Format -R Reverse order + -a All recipients (including delivered) EOF } sub collect() { - open(QUEUE,"$exim $eargs |") or die("Error openning pipe: $!\n"); + open(QUEUE,"$exim $eargs |") or die("Error opening pipe: $!\n"); while() { chomp(); my $line = $_; #Should be 1st line of record, if not error. - if ($line =~ /^\s*(\w+)\s+((?:\d+(?:\.\d+)?[A-Z])?)\s*(\w{6}-\w{6}-\w{2})\s+(<.*?>)/) { + if ($line =~ /^\s*(\w+)\s+((?:\d+(?:\.\d+)?[A-Z]?)?)\s*(\w{6}-\w{6}-\w{2})\s+(<.*?>)/) { my $msg = $3; $id{$msg}{age} = $1; $id{$msg}{size} = $2; @@ -115,13 +121,13 @@ sub selection() { foreach my $msg (keys(%id)) { if ($opt{f}) { # Match sender address - next unless ($id{$msg}{from} =~ /$opt{f}/); + next unless ($id{$msg}{from} =~ /$opt{f}/i); } if ($opt{r}) { # Match any recipient address my $match = 0; foreach my $rcpt (@{$id{$msg}{rcpt}}) { - $match++ if ($rcpt =~ /$opt{r}/); + $match++ if ($rcpt =~ /$opt{r}/i); } next unless ($match); }