Forum Discussion
crosson_16669
Nimbostratus
Jan 08, 2013Read the contents of a file as a string
Since tcl [open filename] is a disabled command how do I read the contents of a stored file as a string?
I need to store several scripts and run eval against them. It makes more sense to ...
hoolio
Cirrostratus
Jan 08, 2013Here's an untested example. Please test it on a VE or non-production unit.
Raw commands on one line separated by a delimiter
log local0. "exec'd command 1"|log local0. "exec'd command 2"
URL encoded copy (http://www.opinionatedgeek.com/DotNet/Tools/UrlEncode/Encode.aspx)
log%20local0.%20%22exec'd%20command%201%22%0d%0alog%20local0.%20%22exec'd%20command%202%22
Add to a data group:
class commands_class {
{
"log%20local0.%20%22exec'd%20command%201%22%0d%0alog%20local0.%20%22exec'd%20command%202%22"
}
}
Use the class command in an iRule to parse the data group
when RULE_INIT {
set url_encoded [class element -name 0 commands_class]
foreach cmd [split [URI::decode $url_encoded] "|"] {
log local0. "About to eval: $cmd"
eval $cmd
}
}
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