You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by fe...@apache.org on 2007/01/25 23:12:54 UTC
svn commit: r500015 - /spamassassin/trunk/contrib/samailoffset
Author: felicity
Date: Thu Jan 25 14:12:53 2007
New Revision: 500015
URL: http://svn.apache.org/viewvc?view=rev&rev=500015
Log:
Add in my samailoffset script which can be used to retrieve messages from a
corpus, mostly for use with mass-check logs.
Added:
spamassassin/trunk/contrib/samailoffset (with props)
Added: spamassassin/trunk/contrib/samailoffset
URL: http://svn.apache.org/viewvc/spamassassin/trunk/contrib/samailoffset?view=auto&rev=500015
==============================================================================
--- spamassassin/trunk/contrib/samailoffset (added)
+++ spamassassin/trunk/contrib/samailoffset Thu Jan 25 14:12:53 2007
@@ -0,0 +1,51 @@
+#!/usr/bin/perl -w
+
+#
+# samailoffset - Easy way to get messages from mass-check log output
+#
+# By: Theo Van Dinter (felicity@apache.org) (c) 1998-2007
+# Revision Info: $Id$
+#
+
+# this script will grab messages out of a corpus and display the headers (by
+# default) or the full message (-b). typically this lets you do something
+# like "grep RULE_NAME ham.log | samailoffset" and get the right thing.
+
+use strict;
+$|++;
+my $body = 0;
+
+# if "-b" is given on the command, this will output the body of the message as
+# well as the header.
+if ( @ARGV && $ARGV[0] =~ /^-+b/ ) { $body=1; shift; }
+unless (@ARGV) {
+ @ARGV=<STDIN>;
+}
+
+foreach ( @ARGV ) {
+ next if /^#/;
+
+ if (/^[.Y]\s+-?\d+\s(.+?)\s(?:[A-Za-z0-9_,]+\s)?[a-z]+=/) {
+ $_ = $1;
+ }
+
+ my $count = 0;
+ /^(.+?)(?:\.(\d+))?$/;
+ my($file,$offset) = ($1,$2);
+
+ if ($file =~ /\.gz$/) {
+ $file = "gunzip -cd $file |";
+ }
+ elsif ($file =~ /\.bz2$/) {
+ $file = "bzip2 -cd $file |";
+ }
+
+ open(T,$file) || die "Can't open $file: $!";
+ seek T, $offset, 0 if (defined $offset);
+ while(defined(my $l=<T>)) {
+ last if ($count++ && $l=~/^From /);
+ print $l;
+ last if (!$body && $l=~/^$/);
+ }
+ close(T);
+}
Propchange: spamassassin/trunk/contrib/samailoffset
------------------------------------------------------------------------------
svn:executable = *
Propchange: spamassassin/trunk/contrib/samailoffset
------------------------------------------------------------------------------
svn:keywords = id
Re: svn commit: r500015 - /spamassassin/trunk/contrib/samailoffset
Posted by Theo Van Dinter <fe...@apache.org>.
On Thu, Jan 25, 2007 at 11:26:22PM +0000, Justin Mason wrote:
> doesn't masses/mboxget do that?
I mentioned that to folks, but they still requested my script, so I threw it
in. In hindsight, I could just have put up an URL to get it from my machine.
--
Randomly Selected Tagline:
"But you have to allow a little for the desire to evangelize when you
think you have good news." - Larry Wall