Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Mar 2002 23:46:51 -0800
From:      spe <bsd@internewscorp.com>
To:        Brendan McAlpine <bmcalpine@macconnect.com>
Cc:        questions@FreeBSD.ORG
Subject:   Re: Mail scanner script?
Message-ID:  <61788037943.20020315234651@telus.net>
In-Reply-To: <B8B84E93.B69C%bmcalpine@macconnect.com>
References:  <B8B84E93.B69C%bmcalpine@macconnect.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Hello Brendan,

Friday, March 15, 2002, 10:21:23 PM, you wrote:

> Does anyone have a shell or perl script that can do the following....

> I want a script that can scan the headers of email files Išve saved and grab
> the from addresses and put them into a separate text file.  Seems simple,
> but I donšt really know how to piece that together.

> Any input or scripts would be appreciated.

Here's something lo-fi . If the body of the mail is still present (not sure if
you're just saving just the headers or what) then lines in the body
that start 'From :' would give false positives.

There are some perl modules for processing email. I'd be surprised if
you didn't find exactly what you're looking for. Every time I need
something it's right there on the shelf. Like Tony the tiger says,
"it's greeeeaaat!"


#!/usr/bin/perl
#
# headerfile - file containing headers
# fromlist   - extracted from information

open(HEADERFILE, "<headerfile") || die "couldn't open headerfile,
dude: $!";
open(FROMLIST, ">fromlist") || die "couldn't open fromlist, guy: $!";

while(<HEADERFILE>) {
      if( m/^From: (.*)/) {
        print FROMLIST "$1\n";
       }
}
close (HEADERFILE) || die "couldn't close headerfile: $!";
close (FROMLIST) || die "couldn't close fromlist: $!";



> Thanks

> Brendan



-- 
Regards,
 spe                            mailto:bsd@internewscorp.com



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?61788037943.20020315234651>