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, 2013If you're on 11.x, like Nitass showed, iFiles would be a simple solution for this. Else, you could URI encode the script, add it to a datagroup (external or internal) and then retrieve the content using the class command and decode it using URI::decode.
That said, if you are eval'ing raw content, make sure you sanitize the input. Else, you'll cause a runtime TCL error and close the client connection or worse, potentially crash TMM.
iFiles wiki page
https://devcentral.f5.com/wiki/iRules.ifile.ashx
Class command wiki page
https://devcentral.f5.com/wiki/iRules.class.ashx
v10 data group formats
https://devcentral.f5.com/Tutorials/TechTips/tabid/63/articleType/ArticleView/articleId/1086448/iRules-Data-Group-Formatting-Rules.aspx
v11 data group formats
https://devcentral.f5.com/Tutorials/TechTips/tabid/63/articleType/ArticleView/articleId/1086510/v11-iRules-Data-Group-Updates.aspx
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