# Switch Statement - action

**URL:** <https://community.f5.com/t/switch-statement-action/39885>\
**Category:** Technical Forums\
**Tags:** dev, irules, devops, application-delivery\
**Created:** [January 23, 2013, 9:19pm UTC](https://community.f5.com/t/switch-statement-action/39885 "2013-01-23T21:19:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![farache\_28983](https://avatars.discourse-cdn.com/v4/letter/f/e99b99/32.png) [@farache\_28983](https://community.f5.com/u/farache_28983)\
**Post date:** [January 23, 2013, 9:19pm UTC](https://community.f5.com/t/switch-statement-action/39885/1 "2013-01-23T21:19:26Z")

</div>

I am building an irule for a specific project and thought of doing a piece of it like this..

when HTTP\_REQUEST priority 150 {

if { $preprodpoolcheck == 1} {

if {[class match [string tolower [HTTP::path]] contains Domain\_collapse\_uri\_list]} {

set ASPserver 1

log local0.alert “Request is for ASP server”

} else {

[switch -glob [string tolower [HTTP::path]] {

“\*.asp” -

“/images/\*” -

“/extras/images/\*” {set ASPserver 1}}]

[switch -glob [string tolower [HTTP::uri]] {

“\*/default.asp” {set JSPserver 1}

default {set JSPserver 1}}]

}

}

log local0.alert “Selected Pre-Prod Servers”

}

Is this really possible? I would guess yes… but again i am not an expert…

I am getting this error in the logs

Rule /Common/pre-prod : PrePROD POOL is LIVE

Jan 23 17:55:15 tmm err tmm[9493]: 01220001:3: TCL error: /Common/pre-prod - invalid command name “” while executing “[switch -glob [string tolower [HTTP::path]] { “\*.asp” - “/images/\*” - “/extras/images/\*” {set ASPserver 1}}]”

I want to set a value to a variable depending on the URL selected.

Any ideas?

---

<div class="post-metadata">

**Author:** ![What\_Lies\_Bene1](https://avatars.discourse-cdn.com/v4/letter/w/59ef9b/32.png) [@What\_Lies\_Bene1](https://community.f5.com/u/What_Lies_Bene1)\
**Post date:** [January 23, 2013, 11:01pm UTC](https://community.f5.com/t/switch-statement-action/39885/2 "2013-01-23T23:01:45Z")

</div>

Remove the first [ from the following;

```tcl
[switch -glob [string tolower [HTTP::path]] {
[switch -glob [string tolower [HTTP::uri]] {

```

---

<div class="post-metadata">

**Author:** ![What\_Lies\_Bene1](https://avatars.discourse-cdn.com/v4/letter/w/59ef9b/32.png) [@What\_Lies\_Bene1](https://community.f5.com/u/What_Lies_Bene1)\
**Post date:** [January 23, 2013, 11:02pm UTC](https://community.f5.com/t/switch-statement-action/39885/3 "2013-01-23T23:02:51Z")

</div>

And the last ] from this line;

```tcl
default {set JSPserver 1}}]

```
