procmail
[Top] [All Lists]

Re: procmail 'if' statements

2003-12-31 11:07:32
On Wed, Dec 31, 2003 at 09:18:41AM -0800, James Marhaus wrote:

Lee wrote:

Now, I want to do things in my recipe depending on the value of
SQLRESULT. procmail does not do conventional if() statements
(right?), so how do I check the value of SQLRESULT?

There might be a more efficient procmail-only method for conditional
equality, but it can be done using the shell:

:0
* ? test $SQLRESULT -lt 8 || test $SQLRESULT -gt 16
dosomething

Did you really want $SQLRESULT to be either less than 8 or
greater than 16?  I somehow composed the below thinking *between*
8 and 16 (inclusive).  Well, for less than 8 or greater than
16, the concept is the same as below, but the specific math
operations are different, of course.  Anyway, here's what I
just wrote and was about to send when I saw the "||" above:


Use scoring to do it all in procmail.  See "man procmailsc".

  LOWER_BOUND =  8
  UPPER_BOUND = 16
  TINY        =  0.000001

  :0
  * $    $SQLRESULT^0
  * $         $TINY^0
  * $ -$LOWER_BOUND^0
  {
     # We're above the lower bound

     :0
     * $ $UPPER_BOUND^0
     * $        $TINY^0
     * $  -$SQLRESULT^0
     | do_something

  }

-- 
dman

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

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