Community discussions

Search found 13 matches

by A9691
Thu Sep 12, 2019 4:24 pm
Forum: Scripting
Topic: parameters for scripting
Replies: 6
Views: 3680

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] > :put [$fac...
by A9691
Thu Jan 03, 2019 2:03 pm
Forum: Announcements
Topic: v6.43.8 [stable] is released!
Replies: 169
Views: 33863

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: 33863

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 repeated right away: /syst...
by A9691
Mon Apr 23, 2018 1:33 pm
Forum: Announcements
Topic: v6.42 [current]
Replies: 147
Views: 28182

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: 28182

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="lant" pin="000...
by A9691
Wed Apr 04, 2018 3:25 pm
Forum: Announcements
Topic: v6.41.3 [current]
Replies: 139
Views: 31280

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] /interface> set p...
by A9691
Thu Mar 01, 2018 10:19 pm
Forum: Scripting
Topic: Scripting - Asking user for input.
Replies: 7
Views: 2625

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: 740

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 set th...
by A9691
Thu Dec 28, 2017 1:02 pm
Forum: Scripting
Topic: get ethernet status rate
Replies: 3
Views: 2850

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 advertising] ....
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: 2861

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: 2922

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: 1349

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-prefix 192.168.2.100/24
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: 740

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 value to the variab...