Forum Discussion
Jun 24, 2015
Hi Leo,
the
scan
in your code works fine to remove the trailing route domain information.In my sample (tested on TMOS v10.2.4) below I use
getfield
instead.I´m testing for the variable and validate the IPv4 address before logging it.
In case the variable does not exist or
catch
detects an invalid IPv4 address an error will be logged.
set client_ip "[getfield [IP::client_addr] "%" 1]"
if { [info exists client_ip] } {
if { [catch {IP::addr ${client_ip} mask 255.255.255.255}] } {
log local0. "error: no valid IPv4 address found (${client_ip})"
} else {
log local0. "address found (${client_ip})"
}
} else {
log local0. "error: variable \$client_ip does not exist"
}
Regarding the error: I guess the result of the scan may contain white space characters or invalid characters causing the TCL error. My sample code might help to figure out these strings.
Thanks,
Stephan