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 ...
Jul 12, 2007
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 switch
when 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
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
