From owner-freebsd-questions Fri Mar 15 23:36:14 2002 Delivered-To: freebsd-questions@freebsd.org Received: from priv-edtnes12-hme0.telusplanet.net (fepout4.telus.net [199.185.220.239]) by hub.freebsd.org (Postfix) with ESMTP id 0A80A37B416 for ; Fri, 15 Mar 2002 23:36:09 -0800 (PST) Received: from FRED ([142.173.43.70]) by priv-edtnes12-hme0.telusplanet.net (InterMail vM.5.01.04.01 201-253-122-122-101-20011014) with ESMTP id <20020316073608.KVIK9959.priv-edtnes12-hme0.telusplanet.net@FRED>; Sat, 16 Mar 2002 00:36:08 -0700 Date: Fri, 15 Mar 2002 23:46:51 -0800 From: spe X-Mailer: The Bat! (v1.51) Reply-To: spe Organization: yes X-Priority: 3 (Normal) Message-ID: <61788037943.20020315234651@telus.net> To: Brendan McAlpine Cc: questions@FreeBSD.ORG Subject: Re: Mail scanner script? In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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, "fromlist") || die "couldn't open fromlist, guy: $!"; while() { 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