procmail
[Top] [All Lists]

Re: How to parse and resent info embeeded in an email

2001-07-25 07:13:46
* Errol Casey <errol(_at_)pobox(_dot_)com> [010725 09:12]:
I'm interested in parsing out some summary weather info,
and then put it into a "subject" line to be emailed.


WEATHER-----------
TODAY:
  High 88F; Low 72F. Humid; breezy later.
  Ozone -
TOMORROW:
  High 87F; Low 70F. A few t-storms and humid.

Is the sample text. I've pulled subjects out of emails, etc
with formail -- but this is the first time I want to pull something
out of a body, and then resend it as a subject in an email

i.e. get weather info, put into a one line string, send email with subject of 
parsed info.

If anybody has any suggestions I would appreciate it.

Perhaps use sed.  For example (very very untested):

:0b
* ^From: whoever
* B ?? ^WEATHER------
{
    # compress part of the body into one line
    SUBJ=`| sed -ne '/TODAY:/ { N;N;N;N; s/\n/ /g; s/  */ /g; p;q; }'`
    :0
    | formail -I "Subject: $SUBJ" | $SENDMAIL -oi you(_at_)some(_dot_)where
}

-- 
- Matt Dunford <> zoot(_at_)zotikos(_dot_)com ..
-. www.zotikos.com -- o,;-
        
Jesus said, "Those who seek should not stop seeking until they find.
When they find, they will be disturbed. When they are disturbed, they
will marvel, and will reign over all. [And after they have reigned
they will rest.]"
  --Saying 2 from the Gospel of Thomas
--
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail