Forum Discussion
Amy_Allen_570
Nimbostratus
Feb 14, 2007Problem with state status after toggle
Hello all,
I am having problem when I use togglePoolMember.pl to change status of member's state. For example, when I run togglePoolMember.pl, state status change to DISABLE from ENABLE. But...
May 24, 2006
The "string first" command will return the index of the found string or -1 if it's not found. So valid values or -1 (for not found) and 0 to len-1 if the string is found. If you are converting this to a boolean value for the if condition, then the only thing that would fail would be a value of 0 (or when the string starts with your substring). I don't think this is what you want. I'd specifically check that the return value is != -1.
Also, you are using matches_regex when you don't need to. Since you are just looking for the start of the string, the "starts_with" operator is much more efficient. You should avoid regular expressions unless there is no alternative.
Give this a shot:
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/servlet/mike" or
[HTTP::uri] starts_with "/servlet/chad" } {
if {-1 != [string first -nocase "deere" [HTTP::host]]} {
log "deere [HTTP::host]"
redirect to "http://unavailable.deere.com/index.pl?SiteName=unavailable.deere.com"
} else {
log "no deere [HTTP::host]"
redirect to "http://x.x.x.x/index.pl?SiteName=unavailable.com"
}
}
log "fell thru [HTTP::host]"
}
You also might need a "string tolower" in there for the HTTP::uri check...
-Joe