procmail
[Top] [All Lists]

Re: Automatic uudecode?

1997-01-27 19:19:58
On Mon, 27 Jan 1997 08:51:17 +0100 (MET) jonas(_at_)coyote(_dot_)eu(_dot_)org 
(Jonas
Oberg) wrote:

I receive quite a lot of soundfiles from a source via e-mail, all
of them is uuencoded. Is it possible to use procmail to automatically
decode these binaries, place them in a special subdirectory and remove
the e-mail?

I've included two recipes below.  

Keep in mind that you need to do additional procesing to remove any text
outside the begin/end lines, before passing the text to uudecode.
uudecode will choke if if encounters lines that are not part of the
uuencoded data.  Something like:

awk '/begin/,/end/'

Should do the trick.

The first recipe is trivial.  It checks for the begin and end lines, and
if they're both there, pipes the message through uudeocde via awk.

# This checks the message body for a 'begin' line, and if it finds one
# uudecodes the message.

:0bDB
* ^begin
* ^end$
| (cd files_directory; awk '/begin/,/end/' | uuconvert)

The second recipe uses a slightly more stringent test -- the message
must have at least 3 lines beginning with 'M' to be considered a
uuencoded message.

# This recipes uses a slightly stronger check to detect a uuencoded
message
# It looks for begin & end lines and *at least* two lines beginning with
'M'.

:0bDB
* -1^0
* ^begin
* ^end$
* 1^1 ^M
| (cd files_directory; awk '/begin/,/end/' | uuconvert)

Enjoy,

-- Lars

---
Lars Kellogg-Stedman * lars(_at_)bu(_dot_)edu * (617)353-8277
Office of Information Technology, Boston University

<Prev in Thread] Current Thread [Next in Thread>