System information
Manual:Scripting
31
pick :pick <var>
<start>[<end>]
return range of elements or substring. If end
position is not specified, will return only one
element from an array.
:put [:pick "abcde" 1 3]
log :log <topic>
<message>
write message to system log. Available topics are
"debug, error, info and warning"
:log info "Hello from script";
time :time <expression> return interval of time needed to execute
command
:put [:time {:for i from=1 to=10
do={ :delay 100ms }}];
set :set <var>
[<value>]
assign value to declared variable. :global a; :set a true;
find :find <arg> <arg>
<start>
return position of substring or array element :put [:find "abc" "a" -1];
environment :environment print
<start>
print initialized variable information :global myVar true; :environment
print;
terminal terminal related commands
error :error <output> Generate console error and stop executing the
script
parse :parse
<expression>
parse string and return parsed console
commands. Can be used as function.
:global myFunc [:parse ":put
hello!"];
$myFunc;
resolve :resolve <arg> return IP address of given DNS name :put [:resolve
"www.mikrotik.com"];
toarray :toarray <var> convert variable to array
tobool :tobool <var> convert variable to boolean
toid :toid <var> convert variable to internal ID
toip :toip <var> convert variable to IP address
toip6 :toip6 <var> convert variable to IPv6 address
tonum :tonum <var> convert variable to integer
tostr :tostr <var> convert variable to string
totime :totime <var> convert variable to time
Menu specific commands
Following commands available from most sub-menus:
Command Syntax Description
add add
<param>=<value>..<param>=<value>
add new item
remove remove <id> remove selected item
enable enable <id> enable selected item
disable disable <id> disable selected item
set set <id>
<param>=<value>..<param>=<value>
change selected items parameter, more than one parameter can be specified at the
time. Parameter can be unset by specifying '!' before parameter.
Example:
/ip firewall filter add chain=blah action=accept
protocol=tcp port=123 nth=4,2
print
set 0 !port chain=blah2 !nth protocol=udp