Hi ALL,
Actually the command can be multiple liner. Only the issue is: read-ability of the codes are terrible.
Example iRules with normally written using iRules Editor:
[root@BigIP:Active:Standalone] config tmsh list ltm rule Eval_Command
ltm rule Eval_Command {
when HTTP_REQUEST {
set Command [string map {/ " "} [HTTP::uri]]
if { $Command eq " " } {
HTTP::respond 200 content "Usage: /Command/Argument_1/Argument_2/Argument_3/.../Argument_N/\r\n" noserver "Connection" "Close"
} else {
HTTP::respond 200 content "$Command\r\n\r\n[eval $Command]\r\n\r\n<--- [clock format [clock seconds] -format "%Y-%m-%d %H:%M:%S"] --->\r\n" noserver "Connection" "Close"
}
}
}
[root@BigIP:Active:Standalone] config
with CLI (tmsh), you can write it as below:
[root@BigIP:Active:Standalone] config tmsh create ltm rule Test_iRules_CLI `echo "when HTTP_REQUEST { set Command [string map {/ \" \"} [HTTP::uri]] ; if { \\$Command eq \" \" } { HTTP::respond 200 content \"Usage: /Command/Argument_1/Argument_2/Argument_3/.../Argument_N/\\\r\\\n\" noserver \"Connection\" \"Close\" } else { HTTP::respond 200 content \"\\$Command\\\r\\\n\\\r\\\n[eval \\$Command]\\\r\\\n\\\r\\\n<--- [clock format [clock seconds] -format \"%Y-%m-%d %H:%M:%S\"] --->\\\r\\\n\" noserver \"Connection\" \"Close\" } }"`
[root@BigIP:Active:Standalone] config
the result will be:
[root@BigIP:Active:Standalone] config tmsh list ltm rule Test_iRules_CLI
ltm rule Test_iRules_CLI {
when HTTP_REQUEST { set Command [string map {/ " "} [HTTP::uri]] ; if { $Command eq " " } { HTTP::respond 200 content "Usage: /Command/Argument_1/Argument_2/Argument_3/.../Argument_N/\r\n" noserver "Connection" "Close" } else { HTTP::respond 200 content "$Command\r\n\r\n[eval $Command]\r\n\r\n<--- [clock format [clock seconds] -format "%Y-%m-%d %H:%M:%S"] --->\r\n" noserver "Connection" "Close" } }
}
[root@BigIP:Active:Standalone] config
Hope the above helps.