Forum Discussion

wlepkin_98758's avatar
Icon for Nimbostratus rankNimbostratus
Jan 14, 2012

Compound conditional expression

Hi, I'm really struggling with what ought to be a pretty simple compound expression. I want to do something like this:



if { ( $a contains "aaa" ) and (( $b equals "123" ) or ( $b equals "456" )) } then { do something }



but I just can't figure out the syntax so that the iRule gets accepted without error and does what I want. Parentheses like I have above don't seem to work.



Thanks for whatever help someone can provide.





2 Replies

  • what error did you get?

    [root@ve1023:Active] config  b rule myrule list
    rule myrule {
       when RULE_INIT  {
            set a "aaa"
            set b "123"
            if { ( $a contains "aaa" ) and (( $b equals "123" ) or ( $b equals "456" )) } then { log local0. "gotcha" }
    [root@ve1023:Active] config  tail /var/log/ltm
    Jan 13 23:17:54 local/ve1023 err mcpd[25539]: 01020066:3: The requested rule (myrule) already exists in partition Common.
    Jan 13 23:17:54 local/tmm info tmm[26866]: Rule myrule RULE_INIT: gotcha
  • Huh, whaddya know. I had simplified the actual rule I was having problems with, for purposes of the forum post. When I actually tried the simplified rule it worked, just as it did for you above. I've since modified it to be more like what I really want to do, and it still works, so the error I was getting before was apparently due to some other part of the rule, and I was just misinterpreting the error to be related to the compound condition.



    Thanks much for your help!