procmail
[Top] [All Lists]

Re: extract number out of body and do condition on it

2001-07-03 11:20:54
On  3 Jul, Jill Bird wrote:
| hi
| 
| When a particular mail message comes thru with this in the body:
| 
| 
| Alert        15.222 secs
| 
| I would like to be able to grab the "15" portion - and see if it's
| greater than 40.  If the number is greater than 40 - I would then like
| to send the mail message to someone.
| 
| --------------------------------------------------------------
| :0
| * ^From(_dot_)someone(_at_)somewhere
| * ^Subject:.Alert Message
| {
|         :0 Bc
|         *Server down alarm|100\.000\%
|         ! someone(_at_)somewhere
|         :0 Ac
|         in-testing
| *******EVERYTHING ABOVE WORKS OK*******************
| *******BELOW IS WHERE I NEED HELP*********************
|         :0 Bc
|         * ^Alert \/(\d+)
| 
| I'm not sure what to do?  I THINK that the above line says - if a line
| begins with "Alert" in the body of the message - take the next number
| and place it in $MATCH   (???maybe????)
| 
| Can someone help?
| 
| How do I grab the number - compare it to another number - and if A is
| greater than B - mail the message??
| 

Procmail doesn't know "\d" as shorthand for numeric digits. I think you
need something like (starting from ***BELOW IS WHERE I NEED HELP***):

MATCH    # not sure if this is necessary

:0 Bc
* ^Alert[       ]+\/[0-9]+
* $ ? test $MATCH -gt 40
! someone(_at_)somewhere
    
There is a space and a tab inside the character class immediately
following ^Alert.

-- 
                         /"\
Don Hammond              \ /     ASCII Ribbon Campaign
Raleigh, NC US            X        Against HTML Mail,
                         / \      and News Too

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail