Forum Discussion
Blake_79204
Feb 08, 2012Nimbostratus
lassign alternative
I'm having a hard time finding documentation for this that is specific to Big-IP v 11, but it looks like iRules are based on Tcl 8.4.6. The command lassign wasn't introduced in Tcl until v8.5. This ...
nitass
Feb 10, 2012Employee
e.g.
[root@ve1023:Active] config b virtual bar list
virtual bar {
snat automap
pool foo
destination 172.28.19.79:80
ip protocol 6
rules myrule
profiles {
http {}
tcp {}
}
}
b[root@ve1023:Active] config b rule myrule list
rule myrule {
when RULE_INIT {
set static::fields {result cn goAgent goPolicyHierID goSaleID}
}
when HTTP_RESPONSE {
set content [string trimright [HTTP::payload] "\n"]
set records [split $content "\n"]
table set ntable [llength $records]
for {set i 0} {$i < [llength $records]} {incr i} {
set rec [lindex $records $i]
set fields [split $rec ":"]
for {set j 0} {$j < [llength $fields]} {incr j} {
table set -subtable line$i [lindex $static::fields $j] [lindex $fields $j]
}
}
}
when HTTP_RESPONSE priority 1000 {
for {set i 0} {$i < [table lookup ntable]} {incr i} {
for {set j 0} {$j < [llength $static::fields]} {incr j} {
log local0. "[lindex $static::fields $j]: [table lookup -subtable line$i [lindex $static::fields $j]]"
}
}
}
}
[root@ve1023:Active] config curl http://172.28.19.79/test.html
result1:cn1:goagent1:goplicyhierid1:gosaleid1
result2:cn2:goagent2:goplicyhierid2:gosaleid2
[root@ve1023:Active] config cat /var/log/ltm
Feb 10 05:15:37 local/tmm info tmm[4822]: Rule myrule : result: result1
Feb 10 05:15:37 local/tmm info tmm[4822]: Rule myrule : cn: cn1
Feb 10 05:15:37 local/tmm info tmm[4822]: Rule myrule : goAgent: goagent1
Feb 10 05:15:37 local/tmm info tmm[4822]: Rule myrule : goPolicyHierID: goplicyhierid1
Feb 10 05:15:37 local/tmm info tmm[4822]: Rule myrule : goSaleID: gosaleid1
Feb 10 05:15:37 local/tmm info tmm[4822]: Rule myrule : result: result2
Feb 10 05:15:37 local/tmm info tmm[4822]: Rule myrule : cn: cn2
Feb 10 05:15:37 local/tmm info tmm[4822]: Rule myrule : goAgent: goagent2
Feb 10 05:15:37 local/tmm info tmm[4822]: Rule myrule : goPolicyHierID: goplicyhierid2
Feb 10 05:15:37 local/tmm info tmm[4822]: Rule myrule : goSaleID: gosaleid2
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