Page 1 of 1

Basic Scripting help (yes i have read the wiki but still stuck)

Posted: Fri Oct 19, 2018 11:43 pm
by Rob2001
This is probably scripting 101. I have read the wiki and spent a couple of hours on this.

Below works, and I get WAN1's gateway of 10.10.20.1
:return [/ip dhcp-client get [find interface="WAN1" ] gateway ]}
I now want to put WAN1's gateway into a variable like so:
:global newgw do={ :return [/ip dhcp-client get [find interface="WAN1" ] gateway ]}
When running
:put $newgw
I would expect to see 10.10.201

However, I get this :
;(eval (eval /returnvalue=(eval (eval /ip dhcp-client getnumber=(eval (eval /ip dhcp-client findwhere=$interface;$add-default-route;$default-route-
distance;$use-peer-dns;$use-peer-ntp;$dhcp-options;$script;$status;$address;$netmask;$gateway;$dhcp-server;$primary-dns;$secondary-dns;$primary-ntp
;$secondary-ntp;$caps-managers;$expires-after;$invalid;$dynamic;$disabled;$comment;$.id;$.nextid;$.dead;(= $interface WAN1);5));value-name=gateway)
)))
Why does this happen?

I eventually want to get a new variable to read WAN1GW%WAN1 for example 10.10.20.1%WAN1
:global defRouteWAN1GW ($newgw . "%WAN1")
Any tips will be a great help

Re: Basic Scripting help (yes i have read the wiki but still stuck)

Posted: Sat Oct 20, 2018 12:18 pm
by dasiu
:put [$newgw]

Re: Basic Scripting help (yes i have read the wiki but still stuck)

Posted: Sat Oct 20, 2018 3:47 pm
by Rob2001
Cheers @Dasiu be be sure to try this out later.

So to add %WAN1 to the end of the $newgw will it be:

:Global GatewayWAN1 ( [$newgw] . "%WAN1" )



Sent from my ONEPLUS A5010 using Tapatalk