procmail
[Top] [All Lists]

Re: Sending 110 character messages to pager

1998-09-08 03:57:57
On Thu, 03 Sep 1998 00:07:25 -0700, Bone 
<bone(_at_)REMOVETHIS(_dot_)conk(_dot_)com>
wrote:
I want to send certain incoming email to my pager, which only accepts
messages upto 110 characters in size, so I wanted to break the email down
into multiple messages and send them as seperate emails, with the from and
subject header intact.  My pager service does not count headers as part of
the 110 character limit.  Thanks

Thanks for including all the relevant info. Except do you want the
From: and Subject: repeated on each message? (I've assumed you do.)
This is untested, however:

    :0
    * do it conditionally, perhaps?
    {
        :0hw
        FROMSUBJ=| formail -XFrom: -XSubject:

        :0bw
        | tr -s ' \011\012' ' ' | fold -s -w 110 | \
          while read line; do \
            ( echo "$FROMSUBJ" ; echo ; echo "$line" ) \
              | $SENDMAIL -oi pager(_at_)address(_dot_)somewhere ; done
    }

If I were you, I'd at set an upper limit on how large messages I'd
forward to the pager.

fold(1) wraps lines at the limit set by the -w parameter and -s says
to wrap on the last preceding whitespace character. The tr command
collapses all whitespace sequences into single spaces (which makes
some messages nearly unreadable, but that's what the pager would do to
them anyhow, I imagine). (Not all versions of fold(1) have the -s
option. Writing a Perl script to preformat the messages for the pager
might be an option if your shell scripting tools are daft. Installing
GNU textutils is another option.)

I have links to some alternative attempts at my Procmail links page
at <http://www.iki.fi/~era/procmail/links.html>. See also 
<http://www.xray.mpe.mpg.de/mailing-lists/procmail/1997-12/msg00125.html>

Hope this helps,

/* era */

-- 
Bot Bait: It shouldn't even matter whether  (`')  Just  (`')  http://www.iki
I am a resident of the State of Washington   \/ Married! \/   .fi/~era/

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