Forum Discussion
Eric_Waite_1046
Jan 08, 2007Nimbostratus
findstr
What does the following mean exactly?
set jsess [findstr [HTTP::uri] "jsessionid" 11 "?"]
What would it set the jsess variable in the following request?
http://users.read...
hooleylist
Jan 08, 2007Cirrostratus
Hi Eric,
Here is the wiki page on findstr:Click here
findstr [ []
* Finds the string within and returns a sub-string based on the and from the matched location. Note the following:
* * The argument may be either a character or length.
* * If the argument is not specified, it defaults to zero.
* * If the argument is not specified, it defaults to the end of the string.
To test this, you can create a test rule that logs the results of the findstr command when the rule is initialized. As the HTTP::uri value won't exist at that point, you can save the URI value you want to test as a string in a variable.
when RULE_INIT {
set uri "/readingplus/loginSchool.do;jsessionid=F8E2C6F9B4CB4FA10EB277639AD77E96"
set jsess [findstr $uri "jsessionid" 11 "?"]
log local0. "\$jsess: $jsess"
}
Here is the output from /var/log/ltm:
Jan 8 17:38:21 tmm tmm[1233]: Rule : $jsess: F8E2C6F9B4CB4FA10EB277639AD77E96
So findstr is searching the URI for "jsessionid", skipping 11 characters (the length of jsessionid plus the '=', and returning everything up to the '?' if there is one. If the terminator of '?' isn't found, the entire string after the skip count is returned.
Using a '?' as the terminator here accounts for the possibility of a query string in the URI.
Holler if you have any questions.
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