[SPAM?] Re: Can I use Mutt from Bash to extract attachments into an arbitrary directory?

2016-09-15 Thread Luis Mochan
On Thu, Sep 15, 2016 at 07:55:12AM -0300, Marcelo Laia wrote:
> On 14/09/16 at 08:06pm, Luis Mochan wrote:
>  
> > Maybe you could use the program 'ripmime' directly from bash. I found
> > it in the debian repositories. I use it manually through a mutt macro
> > 
> > macro index Ys "| ~/.mutt/saveattachments\n" "Save attachments"
> > 
>  
> Hi, I try to use your script, nut, when I hint Y, mutt tell me that "Key Y is
> not mapped"
You should first define the macro! You could do it interactively (for
testing purposes) by typing : (colon) followed by the macro definition
above, i.e.,
  :macro index Ys...
by making a text file whose content is the macro definition and
sourcing it from mutt
  :source filename.txt
or by adding it to you ~/.mutt/muttrc file so that it is loaded
automatically on the next mutt startup. Afterwards, you should be
able to call the macro when you are in the 'index' view. You could
replace Ys to the key sequence of your choice to call the macro. 

> 
> What could I doing wrong?
> 
> -- 
> Marcelo
> 

-- 

  o
W. Luis Mochán,  | tel:(52)(777)329-1734 /<(*)
Instituto de Ciencias Físicas, UNAM  | fax:(52)(777)317-5388 `>/   /\
Apdo. Postal 48-3, 62251 |   (*)/\/  \
Cuernavaca, Morelos, México  | moc...@fis.unam.mx   /\_/\__/
GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16  C2DF 5F0A C52B 791E B9EB




[SPAM?] Re: [SPAM?] Re: Can I use Mutt from Bash to extract attachments into an arbitrary directory?

2016-09-15 Thread Marcelo Laia
On 14/09/16 at 08:06pm, Luis Mochan wrote:
 
> Maybe you could use the program 'ripmime' directly from bash. I found
> it in the debian repositories. I use it manually through a mutt macro
> 
> macro index Ys "| ~/.mutt/saveattachments\n" "Save attachments"
> 
 
Hi, I try to use your script, nut, when I hint Y, mutt tell me that "Key Y is
not mapped"

What could I doing wrong?

-- 
Marcelo


[SPAM?] Re: [SPAM?] Re: Can I use Mutt from Bash to extract attachments into an arbitrary directory?

2016-09-15 Thread David Champion
* On 14 Sep 2016, Cameron Simpson wrote: 
> On 14Sep2016 18:35, David Champion  wrote:
> 
> Just an aside, now often do you encounter "/" in a Message-ID? It is legal,
> and has long discouraged me from the otherwise obvious and inuitive
> name-a-file-after-the-message-id.
> 
> > #!/usr/bin/env python
> [...]
> 
> That is very nice, even cleaner than I imagined it might be.

Thanks - yes, my intention was just to demo the approach. I've done
a few MIME walks in Python so this was a simple modification of some
existing code. Even with many years of mutt experience I think rolling
this up last night was faster than getting something steady and sturdy
going with mutt macros, and I have more confidence in it.

There's certainly room to improve if anyone wants to take this further,
and you've raised a good point above. A few things ought to be sanitized
more.

-- 
David Champion • d...@bikeshed.us


signature.asc
Description: PGP signature


[SPAM?] Re: Can I use Mutt from Bash to extract attachments into an arbitrary directory?

2016-09-14 Thread Cameron Simpson

On 14Sep2016 18:35, David Champion  wrote:

I'd be going for the Python stuff, lacking your context.

See attached.
You can pipe a message into this program (within mutt or elsewhere):
| mutt-savefiles /tmp/foo

It will create a directory under /tmp/foo named for the message's
message-id, and store each attachment inside. Filenames are taken
from the MIME or generated sequentially if there is no filename.


Just an aside, now often do you encounter "/" in a Message-ID? It is legal, and 
has long discouraged me from the otherwise obvious and inuitive 
name-a-file-after-the-message-id.



#!/usr/bin/env python

[...]

That is very nice, even cleaner than I imagined it might be.

Cheers,
Cameron Simpson 


[SPAM?] Re: Can I use Mutt from Bash to extract attachments into an arbitrary directory?

2016-09-14 Thread Luis Mochan
On Wed, Sep 14, 2016 at 04:12:48PM -0700, Are Troi wrote:
> Hi All,
> 
> Last night at a technical talk I lamented the loss around 5 years ago
> from Fedora of command-line tools to extract email attachments from a
> BASH script and a colleague told me Mutt can do this.
> ...

Maybe you could use the program 'ripmime' directly from bash. I found
it in the debian repositories. I use it manually through a mutt macro

macro index Ys "| ~/.mutt/saveattachments\n" "Save attachments"

in my muttrc file. The script 'saveattachments' is the following

#!/bin/bash
# put filenames into arguments
# empty directory unless it is already empty
set - ~/attachments/*   
[ "$*" != "$HOME/attachments/*" ] && rm ~/attachments/*
ripmime -i - -d ~/attachments

I always use the same directory to save the attachments manually, but
I guess the lines above may be modified to let mutt save the
attachments automatically in the desired directory.

-- 

  o
W. Luis Mochán,  | tel:(52)(777)329-1734 /<(*)
Instituto de Ciencias Físicas, UNAM  | fax:(52)(777)317-5388 `>/   /\
Apdo. Postal 48-3, 62251 |   (*)/\/  \
Cuernavaca, Morelos, México  | moc...@fis.unam.mx   /\_/\__/
GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16  C2DF 5F0A C52B 791E B9EB