Have some code. Share some code.
Showing results for 
Search instead for 
Did you mean: 

Problem this snippet solves:

Whist you can log to /var/log/ltm from an iRule, the TCL implementation on TMOS has its file reading and writing capabilities disabled.

However it is still possible to write to a non-logging file to the file system using iRules LX, albeit, to the iRules LX workspace. A second script would be required to move the file to where you require it.

This demo writes a file test.txt containing a client IP address to the iRules LX workspace

How to use this snippet:

First you need an iRule that passes the client IP address into iRules LX (you'll want to put the LX call in a catch for a prod environment)

    set rpcHandle  [ILX::init "fs-pl" "fs-ex"]
    set result [ILX::call $rpcHandle "writeFile" "[IP::client_addr]"]
    log local0. "$result"

Then a simple iRules LX script that will write out a test file with the value of the IP you passed in.

It will write out the file to the extension folder which will vary.. it will also change slightly each time it executes


For example, my file was located here:



The next time, it was located here:


Code :

var f5 = require('f5-nodejs');
var ilx = new f5.ILXServer();
var fs = require('fs');
function writeFile(req, res) {
    var ip = req.params()[0];
    fs.writeFile('test.txt', ip, function(err) {
        if (err) {
        } else {
            res.reply('file written successfully');
ilx.addMethod('writeFile', writeFile);

Tested this on version:

No Version Found
Version history
Last update:
‎01-Jul-2019 02:54
Updated by: