Forum Discussion
Steve_Brown_882
Aug 12, 2011Historic F5 Account
Issue with scan commend?
I am working on what should be a really simple irule, but for some reason I cannot get the scan command to work. I have simplified the entire rule down to the following code to trouble shoot.
when HTTP_REQUEST {
set hh [string tolower [HTTP::host]]
log local0.info "$hh"
scan $hh %s.%s.%s.%s h1 h2 h3 h4
log local0.info "$h1 $h2 $h3 $h4"
}
The first log statement works and produces a log with something in the format of "sub.host.domain.suf" but I get an error when the second log fires.
TCL error: sample_scan - can't read "h2": no such variable while executing "log local0.info "$h1 $h2 $h3 $h4""
I am just formatting the scan wrong?
- Muhammad_64435NimbostratusHi Steve, try this
when HTTP_REQUEST { set host [HTTP::host] log local0. "host -> $host" scan $host {%[^.].%[^.].%s} h1 h2 h3 log local0. "host -> $host ; h1 -> $h1 ; h2 -> $h2 ; h3 -> $h3" }
- Colin_Walker_12Historic F5 AccountMuhammad's got it right, although you'd need one more iteration if you wanted 4 sections. The reason that your %s wasn't working is that it is greedy and eats up everything until the next space, including the "." characters.
% set hh sub.host.domain.suf sub.host.domain.suf % scan $hh {%[^.].%[^.].%[^.].%[^.]} sub host domain suf %
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