Forum Discussion
juan_baptiste_4
Nimbostratus
Oct 14, 2009Define custom function (command ?)
Hi,
I have an irule that needs to execute some code in two different events, so to not have to put the same code twice in each event I would like to put that code in a function that I ...
Oct 14, 2009
proc's are disabled from within iRules due to performance issues with their blocking nature. If you want to use a set of code that functions on two events, your best bet is to write it twice. Another option is to define the TCL code in a global variable and then use the TCL eval command to execute it. This bypasses any of the load time error checking so use it at your own risk.
when HTTP_REQUEST {
set code {log local0. "this is executed from an eval statement"}
set error [catch { eval $code; } errVar];
if { $error } {
log local0. "Error in code execution: $errVar";
}
}
Hope this helps...
-Joe
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