Article View: comp.sys.next.misc
Article #661Re: Stripping mail headers
From: Alex D. Nghiem
Date: Mon, 03 Aug 1992 22:57
Date: Mon, 03 Aug 1992 22:57
90 lines
3390 bytes
3390 bytes
Grant:
I wrote the following shell script to cut out the mail headers and the "cut
here" that is inserted by the mail server at nova.cc.purdue.edu. Maybe you can
modify it to do what you need. To use this shell script:
1. create a temporary mailbox -- call it temp
2. transfer the files you want to the mailbox: it's important that you transfer
them in order, since this basically writes the text to a file, and you need the
text to be in order (otherwise, uudecode will fail). Additionally, you need to
compact the mailbox to make sure there's no extraneous data
3. cd ~/Mailboxes/temp.mbox and copy the mbox file to /tmp
4. run this shell script and redirect the output to a file, which removes all
the mail headers and "cut here" from the file
5. uudecode the resulting file and you're set!
=====================================================
#!/bin/sh
# shell script to cut and reconstruct files downloaded from
# a mail server
INPUT_FILE=$1
TEMP_FILE=/tmp/line_numbers
SED_FILE=/tmp/cut.sed
# find out how many "cut here" there are in the files
# and at what lines they occur at: use awk to strip
# out the rest of the line and only obtain the line numbers
grep -n "cut here" $INPUT_FILE | awk ' BEGIN { FS=":" } { print $1 } ' >
$TEMP_FILE
# create sed script to delete all the mail headers,
# blank lines and lines with "cut here"
awk '
# read entire file into an array
{
line[NR] = $0
}
END {
print "1," line[1] "d"
i=2
while (i < NR)
{
print line[i] "," line[i+1] "d"
i++
i++
}
print line[NR] "d"
} ' $TEMP_FILE > $SED_FILE
# run sed with the sed script just created to delete
# all mail headers and blank lines
sed -f $SED_FILE $INPUT_FILE
rm -f $TEMP_FILE
=====================================================
Hope this helps...
If I can be of any further help, please feel free to contact me.
Best regards,
Alex Duong Nghiem Phone: (512) 343-1111
Pencom Software Fax: (512) 343-9650
9050 Capital of TX Hwy N. Mail: alex@pencom.com
Suite 300 Mail: co-Xist_support@pencom.com
Austin, TX 78759 Mail: co-Xist_info@pencom.com
USA
****************************
* NeXTMail gladly accepted *
****************************
In article <337@gouche.UUCP> grant@Manticore.COM (Grant J. Munsey) writes:
> I sometimes get several mail messages that are parts of a uuencoded
> file. I want to strip off the mail headers so I can combine the mail
> message bodies and uudecode the result. Can you do this some way from
> NeXT Mail. If not is there some program that takes a sequence of concatinated
> mail messages and stripps the header lines? Thanks,
> ----
> Grant Munsey, Mainticore, Inc. (408)252-1135
> grant@Manticore.COM, uunet!ub-gate!gouche!grant NeXTMail ok.
Technical Details
Message-ID:
<1992Aug3.225738.18343@pencom.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!usc!sdd.hp.com!swrinde!news.dell.com!uudell!pensoft!usenetReferences:
<337@gouche.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!sdd.hp.com!swrinde!news.dell.com!uudell!pensoft!usenet From: alex@laos (Alex D. Nghiem) Newsgroups: comp.sys.next.misc Subject: Re: Stripping mail headers Keywords: mail, uudecode Message-ID: <1992Aug3.225738.18343@pencom.com> Date: 3 Aug 92 22:57:38 GMT References: <337@gouche.UUCP> Sender: usenet@pencom.com (Usenet Psuedo User) Reply-To: alex@pencom.com Organization: Pencom Software Lines: 90