procmail
[Top] [All Lists]

Re: Hard one for the gurus - Extracting files from a uuencoded mess age

2002-08-14 11:59:50
On 14 Aug, Odhiambo Washington wrote:
| 
| Just teasing - I know this is like ice cream for the gurus ;-)
| 
| Hello there,
| 
| I would like to request your help: 
| 
| I do receive virus definition files updates from the address
| subscribe(_at_)drweb(_dot_)ru on a weekly basis.
| 
| The only difficulty I am facing is that the files are UUENCODED into
| the come as the body of the message...something like this:
| 
| begin 644 drw42814.zip
| M4$L#!!0````(`(`C"RW445!KT0P``&`.```,````1%)7-#(X,30N5D1"G9$'
| M4!-:FX9#8(_at_)$C14H0I,0"H80:;'1""46D(T7$8$(+!!**=$(7D(X4I440D-Y"
| M:*%7$11!F(_at_)6EB87>+J!DN;/N[-W9_]][9]^9,^>9]_U.^XX&4?(6U(_at_)[JC25Z
| <snip>
| ...
| ...
| </snip>
| end
| 
| 
| There is exactly one empty line before "begin", then there is one empty
| line after "end", afterwhich there is some text that I would not want.
| 
| 
| I would like to use procmail to automatically extract the files for me
| into some directory. How do I extract the relevant part of the body, pass
| it to uudecode and get the files saved??
| 
| :0B
| * ^From:(_dot_)*subscribe(_at_)drweb(_dot_)ru
||uudecose some_args
| somedir/
| 

You shouldn't need to do anything special because uudecode will igonore
everything before and after the relevant section. It doesn't need to be
stripped down to just the attachment. I don't know what it'll do if
there's more than one attachment, and don't have time to test it, but
that's probably not an issue here.

:0b:uue.lock
* ^From:(_dot_)*subscribe(_at_)drweb(_dot_)ru
*     B ?? ^begin [0-7][0-7][0-7] \/.*
*     B ?? ^end$
* 1^3 B ?? ^M
|uudecode >"/path/to/final/destination/$MATCH"

Adjust the path to the redirected output as needed. The scored condition
will hit supremum and stop counting at 23 lines (but will still match
only one), but might be overkill.

-- 
Reply to list please, or append "8" to "procmail" in address if you must.
Spammers' unrelenting address harvesting forces me to this...reluctantly. 


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail