Forum Discussion
Michael_108908
Jul 12, 2007Historic F5 Account
iRULE genetating an error in ltm log
One of my customers created this iRule:
when HTTP_REQUEST {
if{[[HTTP::header User-Agent] contains "BlackBerry8100"]}
pool BB_Test_Pool
elseif{[[HTTP::header User-Agent] contains "BlackBerry7250"]}
pool BB_TEST_POOL1
}
and it generates the following error:
TCL error: Rule WAP_iRULE HTTP_REQUEST - invalid command name BlackBerry8100/4.2.1 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/149contains while executing [HTTP::header User-Agent]contains BlackBerry8100
According to the iRule editor the rule is syntactically correct. This is my first iRule case and I am a little lost. Can someone please help?
4 Replies
- Michael_108908Historic F5 AccountShould "*BlackBerry8100*" be used instead of "BlackBerry8100"?
- The first clue is always the error message.
if { [[HTTP::header User-Agent] contains "BlackBerry8100"] }
Enclosing the block with brackets tells the TCL engine to execute that code as a procedure. In this case it tries to execute a procedure that is " contains BlackBerry8100" which is why the error of invalid command is given. Fix here is to remove the brackets.
Secondly there is no curly brackets around the code blocks of the if/elseif. Odds are when the first error is corrected, you'll get a syntax error here.
This version should work:when HTTP_REQUEST { if { [HTTP::header User-Agent] contains "BlackBerry8100" } { pool BB_Test_Pool } elseif { [HTTP::header User-Agent] contains "BlackBerry7250" } { pool BB_TEST_POOL1 } }
-or- you could do it this way with a switchwhen HTTP_REQUEST { switch -glob [HTTP::header User-Agent] { "*BlackBerry8100*" { pool BB_Test_Pool } "*BlackBerry7250*" { pool BB_TEST_POOL1 } } }
You pick which one you like better, they should both be functionally equivalent.
-Joe - Michael_108908Historic F5 AccountThank you Joe, I really appreciate your help.
Michael - Anytime...
-Joe
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects