Forum Discussion
Is there any string function that can calculate how many characters in a data variable in irule?
Hello,
For example I would like to know how many characters in [HTTP:uri] , is it possible to do so?
Thanks
- IchnafiCirrostratus
Hi,
give this a try:
string length [HTTP::uri]
- danielcCirrus
Hello,
I have given it a try but faced problem:
when HTTP_REQUEST {
set thisuri [HTTP::uri]
...
}
when HTTP_RESPONSE {
if { [HTTP::status] == 404 } {
if { [ string length $thisuri ] > 2 } {
HTTP::respond 404 content "
<html>
<head>
<title>Not Found</title>
</head>
<body>
<h2>Not Found</h2>
This page is not found.<br>
<p></p>
</body>
</html>
} else {
HTTP::respond 404 content "
<html>
<head>
<title>Not Found</title>
</head>
<body>
<h2>Not Found</h2>
This website is not found.<br>
<p></p>
</body>
</html>
"
}
}But I faced this error
01070151:3: Rule [/Common/check_url] error: /Common/check_url:63: error: [parse error: missing "]["
line 63 is HTTP::respond 404 content "
line 61 is if { [string length $thisuri] > 2 } then {
Any idea? Thanks
- IchnafiCirrostratus
You are missing a quotation mark (") after </html> in the if clause.
May i suggest, that you use a "real" editor to write iRules.
Maybe try VScode with the extension "F5 Network iRules". With propper syntax highlighting errors like this are more easy to spot.- danielcCirrus
Thanks for your suggestion, I am using it, It is too difficult to do the irule programming directly on bigip.
Recent Discussions
Related Content
* 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