Community discussions

MikroTik App
 
Rob2001
just joined
Topic Author
Posts: 11
Joined: Fri Nov 17, 2017 5:21 pm

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

Fri Oct 19, 2018 11:43 pm

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
 
User avatar
dasiu
Trainer
Trainer
Posts: 231
Joined: Fri Jan 30, 2009 11:41 am
Location: Reading, UK
Contact:

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

Sat Oct 20, 2018 12:18 pm

:put [$newgw]
 
Rob2001
just joined
Topic Author
Posts: 11
Joined: Fri Nov 17, 2017 5:21 pm

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

Sat Oct 20, 2018 3:47 pm

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

Who is online

Users browsing this forum: Bing [Bot] and 31 guests