Forum Discussion
Charles_Harris
Feb 12, 2007Nimbostratus
Global Variables in RULE_INIT
Hi,
This is a little strange, but I can't get a global variable defined within an iRule.
Have I got Monday syndrome or does this look odd for example:
when RULE_INIT{
set hello "Why don't I show anything..."
}
when LB_SELECTED{
log "$hello"
}
I just get errors in the LTM log like " - can't read "hello": no such variable"
Any ideas? or have I lost the plot?
Cheers,
-=ChaZ=-
- Joe_D_Rozario_4NimbostratusI don't see any :: in the code !! Try using it.
- James_ThomsonEmployeeThis thread has an example of setting and using a global variable:
- JRahmAdminSo to put that in practice:
- Charles_HarrisNimbostratusThanks everyone! - Monday or just general stupidity on my part?! (the latter is more likely!).
- Just to chime in here for a minute. Variables can be shared across a connection without being in the global scope (ie, using "::"). RULE_INIT is a special rule that is only run at initialization time and not for each connection. So, any local variables created there will not be available across other events. Any variables you want set in RULE_INIT make sure that you use the global scope.
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