<<< Date Index >>>     <<< Thread Index >>>

Re: How do I filter a message?



Am 2005-03-29 19:39:28, schrieb Toby:
> Dear Mutt users,
> 
>       I cannot find a way to filter a message through an external
> program when I press a macro key on it in the index view (or such.)
> I might want to filter the Subject line or another header through sed,
> or possibly pass the message to a script for complex operations.

I use:

  __( '/home/michelle.konzack/.mutt/macros' )___________________________
 /
| macro index <F2>  ":set delete=yesn|tdblacklist 
--addns=.ATTENTION.FLT_blacklist/nn$n:set delete=ask-yesn"
| macro index <F3>  "|tdblacklist --removen"
| macro index <F4>  "|tdblacklist --remove-dialogn"
| 
| macro pager <F2>  ":set delete=yesn|tdblacklist 
--addns=.ATTENTION.FLT_blacklist/nn$n:set delete=ask-yesn"
| macro pager <F3>  "|tdblacklist --removen"
| macro pager <F4>  "|tdblacklist --remove-dialogn"
 \______________________________________________________________________

And then in

  __( '/home/michelle.konzack/bin/tdblacklist' )________________________
 /
| #!/bin/bash
| 
| if [ "$1" ] ; then
|   LIST=$HOME/.procmail/LIST_blacklist
| 
|   if [ "$1" == "--add" ] ; then
|     TMPFILE=`tempfile`
|     cat /dev/stdin >$TMPFILE1
|     FROMTMP=`cat $TMPFILE1 |formail -czxFrom:`
|     echo "$FROMTMP" |grep "<" >/dev/null 2>&1
|     ES1=$?
|     if [ $ES1 == "0" ] ; then
|       FROM=`echo "$FROMTMP" |sed -e "s/^.*<//" -e "s/>.*$//"`
|     else
|       FROM=$FROMTMP
|     fi
|     rm -f $TMPFILE >/dev/null 2>&1
|   fi
| exit 0
 \______________________________________________________________________

Resultat:

  __( '/home/michelle.konzack/.procmail/LIST_blacklist' )_______________
 /
| abuse@xxxxxxxxxxx
| abuse@xxxxxxxxxx
| abuse@xxxxxxxxxxxxx
| abuse@xxxxxxxxxxxxxxxx
| abuse@xxxxxxxxxxxxxxxx
| Admin@xxxxxxxx
| administrateur@xxxxxxxxxxxx

<snip around 600 addresses>

| warnung@xxxxxxxxxx
| Webmaster@xxxxxxxxxxxxxx
| webmaster@xxxxxxxxxxxxxxxx
| webmaster@xxxxxxxxxxxxxxxxxxxx
| webmaster@xxxxxxxxxxxxx
| webmaster@xxxxxxxxxxxxxxxx
| webmaster@xxxxxxxxxxxx
| webmaster@xxxxxxxxxxxxxxxxx
| webmaster@xxxxxxxxxxx
| weitersagen@xxxxxxxxx
| WFM_Email_Gateway@xxxxxxxxxxxxxx
| world_vision01@xxxxxx
| www-style@xxxxxx
 \______________________________________________________________________


> pipe-message on the other hand doesn't seem to be made for filtering
> messages, because it doesn't expect a filtered message in return to
> replace the original message with.

Stop !

The above Examples do only pipe the Message to the script and
this take an action. here it updates a blacklist for procmail.

If you want to edit a message, you need to.

  __( '/home/michelle.konzack/.mutt/macros' )___________________________
 /
| macro index <F6>  ":set editor='tdmailautoedit'\ne\n:set 
editor=/usr/bin/mcedit\n"
| macro pager <F6>  ":set editor='tdmailautoedit'\ne\n:set 
editor=/usr/bin/mcedit\n"
 \______________________________________________________________________

or better

  __( '/home/michelle.konzack/.mutt/macros' )___________________________
 /
| macro index <F6>  ":set pipe_decode=no\n:set editor='tdmailautoedit'\ne\n:set 
editor=/usr/bin/mcedit\n:set pipe_decode=yes\n"
| macro pager <F6>  ":set pipe_decode=no\n:set editor='tdmailautoedit'\ne\n:set 
editor=/usr/bin/mcedit\n:set pipe_decode=yes\n"
 \______________________________________________________________________

In my 'tdmailautoedit' I use 'dialog' where I can choose via "--menu"
what I want to do with the message...

> Any suggestions?
> 
> Toby

Greetings
Michelle

-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/ 
Michelle Konzack   Apt. 917                  ICQ #328449886
                   50, rue de Soultz         MSM LinuxMichi
0033/3/88452356    67100 Strasbourg/France   IRC #Debian (irc.icq.com)

Attachment: signature.pgp
Description: Digital signature