Community discussions

MikroTik App

Search found 16 matches

by A9691
Fri Oct 30, 2020 9:59 am
Forum: Useful user articles
Topic: Advanced Routing Failover without Scripting
Replies: 148
Views: 28118

Re: Advanced Routing Failover without Scripting

Thank you for your answer. I was hoping there was a neat and simple scope/target scope "magic" to solve the problem. This one worked, and I think is still simple enough, one can see how recursive routes work: /ip route add check-gateway=ping comment="default route - recursive via work...
by A9691
Thu Oct 29, 2020 2:02 pm
Forum: Useful user articles
Topic: Advanced Routing Failover without Scripting
Replies: 148
Views: 28118

Re: Advanced Routing Failover without Scripting

I'm trying for some time to figure out how to access both checking hosts when one isp is down? /ip route add check-gateway=ping comment="default route - recursive via working gateway" distance=2 gateway=8.8.4.4 add check-gateway=ping comment="default route - recursive via working gate...
by A9691
Wed Aug 19, 2020 12:27 pm
Forum: Scripting
Topic: How to get current script's filename ? [Help]
Replies: 2
Views: 1068

Re: How to get current script's filename ? [Help]

Not exactly the answer, but instead of /import you could use a $import function. This way you could also pass parameters to script file and return results. :global import do={/import $1; return $result} Create a script file demo.rsc :if ($0 = "\$import") do={ :put "script name: $1&quo...
by A9691
Thu Sep 12, 2019 4:24 pm
Forum: Scripting
Topic: parameters for scripting
Replies: 6
Views: 6232

Re: parameters for scripting

You can pass parameters to script files run with /import. For example: Content of fact.rsc: :if ($1 > 1) do={ :global fact :set $result ([$fact ( $1 - 1 )]*($1)) } else={ :set $result 1 } Define fact function: :global fact do={/import "fact.rsc"; return $result} Testing: [admin@bkeniko] > ...
by A9691
Thu Jan 03, 2019 2:03 pm
Forum: Announcements
Topic: v6.43.8 [stable] is released!
Replies: 169
Views: 51856

Re: v6.43.8 [stable] is released!

There will always be delays before items appear in the table. Slower CPU greater delay.
There is no delay in appearance. The print command finds the entry named A, but the remove command fails regardless.
by A9691
Thu Jan 03, 2019 1:29 pm
Forum: Announcements
Topic: v6.43.8 [stable] is released!
Replies: 169
Views: 51856

Re: v6.43.8 [stable] is released!

The following code fails all the time: /system script environment> :global A 10; remove "A"; :global A 20; print; remove "A" # NAME VALUE 0 A 20 no such item (4) The error message is produced by the last remove command. This is basically the same, but usually works, if not repeat...
by A9691
Mon Apr 23, 2018 1:33 pm
Forum: Announcements
Topic: v6.42 [current]
Replies: 147
Views: 40248

Re: v6.42 [current]

Notice the /delay 20 command before trying to enable the interface. Should that not be :delay 20; ? ..hmm. Interesting. I didn't knew that commands with : can be used with / instead of : ... or something like that. [admin@pincegw] > :global a 10; /set a 5; /put $a 5 Is there any difference between ...
by A9691
Mon Apr 23, 2018 10:49 am
Forum: Announcements
Topic: v6.42 [current]
Replies: 147
Views: 40248

Re: v6.42 [current]

There is bug finding a disabled ppp-client interface. [admin@PinceGW-teszt] > /interface ppp-client [admin@PinceGW-teszt] /interface ppp-client> print Flags: X - disabled, R - running 0 X name="modem" max-mtu=1500 max-mru=1500 mrru=disabled port=usb1 data-channel=0 info-channel=1 apn="...
by A9691
Wed Apr 04, 2018 3:25 pm
Forum: Announcements
Topic: v6.41.3 [current]
Replies: 139
Views: 41495

Re: v6.41.3 [current]

RB2011UAS-2HnD ROS v6.41.3 Enabling pppoe client interface, waiting for a number of seconds (>14 secs), then disabling it results in "no such item (4)" error. Occurs in Winbox and Terminal. Also happens in 6.42rc43 I have the same problem with a PPP Client interface: [admin@teszt] /interf...
by A9691
Thu Mar 01, 2018 10:19 pm
Forum: Scripting
Topic: Scripting - Asking user for input.
Replies: 9
Views: 4569

Re: Scripting - Asking user for input.

Try out the following:
# function to prompt user to enter a value
:global read do={:return}

# storing the value entered by the user
:local userinput [$read]
It is interesting, that if the user enters 192.168.10.0/24, [:typeof $userinput] will be ip-prefix, not str.
by A9691
Thu Mar 01, 2018 9:52 pm
Forum: General
Topic: Is there a concept of "Pointer" like in C language?
Replies: 4
Views: 1094

Re: Is there a concept of "Pointer" like in C language?

... and there is a straightforward method too. See commands available at /system script environment. # pointer: a string containing the name of a global variable :local ptr "x' # function to read the pointed value :global rd do={:return [/system script environment get $1 value]} # function to s...
by A9691
Thu Dec 28, 2017 1:02 pm
Forum: Scripting
Topic: get ethernet status rate
Replies: 3
Views: 4344

Re: get ethernet status rate

:put ([/interface ethernet monitor ether1 once as-value]->"rate") You can also define a function: :global statusinfo do={:return ([/interface ethernet monitor $1 once as-value]->$2) } And then get any status info, like rate: [$statusinfo ether1 rate], advertising: [$statusinfo ether1 adve...
by A9691
Wed Dec 27, 2017 11:46 am
Forum: General
Topic: In 2 WAN interfaces setup, how to ping from the interface with higher distance?
Replies: 5
Views: 5900

Re: In 2 WAN interfaces setup, how to ping from the interface with higher distance?

/ping 8.8.8.8 interface=wan would be nice, but it is not meant for ipv4. But there is a simple workaround. Let's say 10.0.0.1 is the connected gateway for the interface wan. You have to prepare a special routing table: /ip route add gateway=10.0.0.1 distance=1 routing-mark=testwan /ip route add dis...
by A9691
Tue Jul 26, 2016 1:06 pm
Forum: Scripting
Topic: Empty array initialization
Replies: 5
Views: 3779

Re: Empty array initialization

The second solution is the right one: [:toarray ""] is a zero length array.
{""} is an array with one element which is a zero length string.
by A9691
Fri Jul 01, 2016 3:16 pm
Forum: Scripting
Topic: How to convert a string to ip-prefix data type?
Replies: 3
Views: 1803

Re: How to convert a string to ip-prefix data type?

If $ipp is a string containing an ip-prefix then [[:parse ":return ".$ipp]] returns that ip-prefix. A function that does that conversion: :global toipprefix do={:local result [[:parse ":return $1"]]; :return $result} [$toipprefix "192.168.2.100/24"] will evaluate to ip-...
by A9691
Sat May 14, 2016 11:17 am
Forum: General
Topic: Is there a concept of "Pointer" like in C language?
Replies: 4
Views: 1094

Re: Is there a concept of "Pointer" like in C language?

I don't know since which version, but it is possible now (V6.32.1). Try this out in a script: :global variable value :local pointer "variable" :put [ [ parse ":global $pointer; :return \$$pointer"] ] The variable has to be global, but the pointer can be local. You can also assign...