...
Command | Syntax | Description | Example | |||||
---|---|---|---|---|---|---|---|---|
/ | go to the root menu | |||||||
.. | go back by one menu level | |||||||
? | list all available menu commands and brief descriptions | |||||||
global | :global <var> [<value>] | define a global variable | :global myVar "something"; :put $myVar; | |||||
local | :local <var> [<value>] | define the local variable | { :local myLocalVar "I am local"; :put $myVar; } | |||||
beep | :beep <freq> <length> | beep built-in speaker | ||||||
delay | :delay <time> | do nothing for a given period of time | ||||||
put | :put <expression> | put supplied argument to the console | ||||||
len | :len <expression> | return string length or array element count | :put [:len "length=8"]; | |||||
typeof | :typeof <var> | the return data type of variable | :put [:typeof 4]; | |||||
pick | :pick <var> <start>[<count>] | return range of elements or substring. If the count is not specified, will return only one element from an array.
| :put [:pick "abcde" 1 3] | |||||
log | :log <topic> <message> | write a message to the 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 the command | :put [:time {:for i from=1 to=10 do={ :delay 100ms }}]; | |||||
timestamp | returns the time since epoch, where epoch is January 1, 1970, not counting leap seconds |
| ||||||
set | :set <var> [<value>] | assign value to a declared variable. | :global a; :set a true; | |||||
find | :find <arg> <arg> <start> | return position of a 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 | ||||||
execute | :execute <expression> | Execute the script in the background. The result can be written in the file by setting a file parametera "file"parameter or printed to the CLI by setting "as-string". When using "as-string" parameter executed script is blocking (not executed in the background). |
| |||||
parse | :parse <expression> | parse the string and return parsed console commands. Can be used as a function. | :global myFunc [:parse ":put hello!"]; | |||||
resolve | :resolve <arg> | return the IP address of the given DNS name | :put [:resolve "www.mikrotik.com"]; | |||||
retry | :retry command=<expr> delay=[num] max=[num] on-error=<expr> | Try to execute the given command "max" amount of times with a given "delay" between tries. On failure, execute the expression given in the "on-error" block |
| |||||
rndnum | :rndnum from=[num] to=[num] | random number generator | :put [:rndnum from=1 to=99]; | |||||
rndstr | :rndstr from=[str] length=[num] | random string generator |
| |||||
toarray | :toarray <var> | convert variable to the 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 an integer | ||||||
tostr | :tostr <var> | convert variable to a string | ||||||
totime | :totime <var> | convert variable to time |
...