procmail
[Top] [All Lists]

Re: Pager Script

1997-07-11 08:01:00
On 11 Jul 97 08:55:21 EDT, Konstantin Gogos 
<100727(_dot_)703(_at_)CompuServe(_dot_)COM> wrote:
Now, I want to copy the From: and the Subject: line
without the words From: and Subject: to a new Subject with the
maximum size of 100 chars. Then I like to delete the whole
body and forward the result to my pager address.

:0
* conditions
{
    FROMSUBJ=`formail -rtz -xTo: -xSubject: <rmail.out | \
        sed -e '$!N' -e 's/Re: Re: /Re: /' -e 's/\n[    ]*/ /g' | \
        cut -c1-91    # with "Subject: ", 100 characters`

    :0ch
    | formail -I"Subject: $FROMSUBJ" \
        | $SENDMAIL $SENDMAILFLAGS pager(_at_)address
}

You need to make sure your copy of cut(1) understands the -c option.
If you really mean to say there's room for "Subject: " +plus+ 100
characters, you can of course change the cut accordingly. 

The sed script has a couple of idiosyncracies -- I'm lost as to why
this is happening, but it will not unconditionally replace all
newlines with spaces. (This is not normally a problem, but it might
bite if you have a Subject which spans more than one line -- although
in that case, the overspanning will probably disappear after the cut
anyway?) 
  Also, interestingly, formail -rt will add a second Re: on front of
the Subject even if there is already one.

This subject is frequently beaten to death on this list, but I think
the replies you'd have found in the archives are all slightly
different. Nevertheless, check out

<http://www.rosat.mpe-garching.mpg.de/mailing-lists/cgi-bin/w3glimpse/procmail?query=pager&errors=0&case=on>

Hope this helps,

/* era */

-- 
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>

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