Hi
I’m trying to dynamically read global values in a script, based on passed identifier (=label), but I’ve trouble getting the desired effect. Anyone knows how to get the expected result?
[Admin@firewall] > :global extipWan1 "a.b.c.d"
[Admin@firewall] > :return $extipWan1
a.b.c.d
[Admin@firewall] > {:local label "Wan1"; :local wanip; :local cmd ":return \$extip$label"; :put $cmd; :local
getip [:parse $cmd ]; :put $getip; :set $wanip [$getip]; :put $wanip}
:return $extipWan1
(eval /returnvalue=$extipWan1)
[Admin@firewall] >
In the third line I’ve added additional output to validate the string and function.
Thanks
I’ve slightly modified the command to:
[Admin@firewall] > :global extipWan2 "a.b.c.d"
[Admin@firewall] > :return $extipWan2
a.b.c.d
[Admin@firewall] > {:local label "Wan2"; :local wanip "unset"; :local cmd ":return \$extip$label"; :put $cmd; :loc
al getip [:parse $cmd ]; :put $getip; :set $wanip [$getip]; :put $wanip}
:return $extipWan2
(eval /returnvalue=$extipWan2)
[Admin@firewall] >
So:
the “[$getip]” IS EXECUTED but it’s UNABLE to read global variable???
Eureka 
define global variable…
[Admin@firewall] > :global extipWan2 "a.b.c.d"
[Admin@firewall] > :return $extipWan2
a.b.c.d
[Admin@firewall] > {:local label "Wan2"; :local wanip "unset"; :local cmd ":global extip$label; :return \$extip$la
bel"; :put $cmd; :local getip [:parse $cmd ]; :put $getip; :set $wanip [$getip]; :put $wanip}
:global extipWan2; :return $extipWan2
(eval /globalname=$extipWan2);(eval /returnvalue=$extipWan2)
a.b.c.d
[Admin@firewall] >