Forum Discussion
Sayan_81841
Feb 24, 2011Nimbostratus
Switch statement not working
Hi, I wrote an iRule and the content is given below. But this is not working as expected. when HTTP_REQUEST { if { [HTTP::host] starts_with "abc.com" } { set var1 "/abc/x...
hooleylist
Feb 24, 2011Cirrostratus
Hi Sayan,
The curly braces at the beginning and end of the switch statement prevent variable expansion. See this thread for an alternative:
http://stackoverflow.com/questions/3261515/tcl-switch-glob-does-not-match-with-variable
when RULE_INIT {
set var1 "test1"
set var2 "test2"
switch -glob -- "test1mail" $var1 {
log local0. "matched $var1"
} $var2 {
log local0. "matched $var2"
} "${var1}mail" {
log local0. "matched ${var1}mail"
} default {
log local0. "no match"
}
}
: matched test1mail
Aaron
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