views:

461

answers:

4

Hello,

Do you know how to extract attachments from a raw mail message on Unix? I want to do it from shell script (ksh). The mail file is the raw e-mail with headers and encoded attachments..

PS: I can't use perl!

Thx.

+1  A: 

A very long time ago, I used metamail for exactly this sort of thing.

see http://kb.iu.edu/data/aibt.html

M.

Martin Cowie
Thanks, but: metamail: Could not find end of mail headers.I'm on an old HP-Ux B11.11 system..
ExpertNoob1
+2  A: 

I would take a look at MH and its successor, NMH. From the FAQ:

The MH message handling system is a set of electronic mail programs in the public domain. If your computer runs Unix, it can probably run MH.

The big difference between MH and most other "mail user agents" is
that you can use MH from a Unix shell prompt. In MH, each command is a separate program, and the shell is used as an interpreter. So, all the power of Unix shells (pipes, redirection, history, aliases, and
so on) works with MH--you don't have to learn a new interface. Other mail agents have their own command interpreter for their individual
mail commands (although the mush mail agent simulates a Unix shell).

Brian Agnew
MH is dead! Its home is closed: http://www.ics.uci.edu/~mh/.I couldn't even find manual pages..
ExpertNoob1
Edited to refer to NMH
Brian Agnew
I can't compile nmh on my system :'( cc -s -o ali ali.o aliasbr.o ../config/version.o ../config/config.o ../mts/libmts.a ../sbr/libmh.a -lm/usr/ccs/bin/ld: Unsatisfied symbols: _filbuf (first referenced in ../sbr/libmh.a(m_getfld.o)) (code)*** Error exit code 1
ExpertNoob1
+1  A: 

mpack did it for me! (actually the munpack part) Exactly what I needed: tiny standalone executable with no extra.

ExpertNoob1
A: 

Another solution is to use uudeview. Works similar to munpack. Just type

$ uudeview file.eml

Jabba