RouterOS2.96 script details

Source: Internet
Author: User
Tags define local
Article Title: RouterOS2.96 script details. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source. Four Variables
Global-defines global variables, which can be shared by calling all scripts
Local-Defines local variables. They can only be called under the script they want and cannot be shared by other scripts.
Loop index variables-index number variable defined in for or foreach
Monitor variables-monitoring variables

ROS arithmetic operations
-Minus sign.
! Non-logical.
/Division.
. Connection. Join two operators to add elements to the list
^ Exclusive or (XOR)
~ Invert
* Remaining
& AND)
& Logic and
+ Addition
<Less
<Left direction shift
<= Less than or equal
> Greater
> = Greater than or equal
> Shift to the right
| Or
| Logical or

Example in the ROS statement:

Computing Sequence
[Admin @ MikroTik]>: put (10 + 1-6*2 = 11-12 = 2 + (-3) =-1)
False
[Admin @ MikroTik]>: put (10 + 1-6*2 = 11-12 = (2 + (-3) =-1 ))
True

Non-logical
[Admin @ MikroTik]>: put (! True)
False
[Admin @ MikroTik]>: put (! (2> 3 ))
True

Digital Inversion
[Admin @ MikroTik]>: put (~ 255.255.0.0)
0.0.0000255

Addition
[Admin @ MikroTik]>: put (3 ms + 5S)
00:00:05. 003
[Admin @ MikroTik]>: put (10.0.0.15 + 0.0.10.0)
Cannot add ip address to ip address
[Admin @ MikroTik]>: put (10.0.0.15 + 10)
10.0.0.25

Subtraction
[Admin @ MikroTik]>: put (15-10)
5
[Admin @ MikroTik]>: put (10.0.0.15-10.0.0.3)
12
[Admin @ MikroTik]>: put (10.0.0.15-12)
10.0.0.3
[Admin @ MikroTik]>: put (15 h-2 s)
14:59:58

Multiplication
[Admin @ MikroTik]>: put (12 s * 4)
00:00:48
[Admin @ MikroTik]>: put (-5 *-2)
10

Division
[Admin @ MikroTik]>: put (10 s/3)
00:00:03. 333
[Admin @ MikroTik]>: put (5/2)
2
[Admin @ MikroTik]>: put (0: 0. 10/3)
00:00:02

Comparison
[Admin @ MikroTik]>: put (10.0.2.3 <= 2.0.3.10)
False
[Admin @ MikroTik]>: put (100000 s> 27 h)
True
[Admin @ MikroTik]>: put (60 s, 1d! = 1 m, 3600 s)
True
[Admin @ MikroTik]>: put (bridge = routing)
False
[Admin @ MikroTik]>: put (yes = false)
False
[Admin @ MikroTik]>: put (true = aye)
False

Logic AND, logic OR
[Admin @ MikroTik]>: put (yes & yes) | (yes & no ))
True
[Admin @ MikroTik]>: put (no | no) & (no | yes ))
False

Digits AND, OR, exclusive OR XOR
[Admin @ MikroTik]>: put (10.16.0.134 &~ 255.255.255.0)
0.0.0.134

Displacement operation
[Admin @ MikroTik]>: put (~ (0.0.0.1 <7)-1 ))
2017100000000128

Connection operation
[Admin @ MikroTik]>: put (1. 3)
13
[Admin @ MikroTik]>: put (1, 2. 3)
1, 2, 3
[Admin @ MikroTik]>: put (1. 3, 4)
13,4
[Admin @ MikroTik]>: put (1, 2, 3, 4)
1, 2, 3, 4
[Admin @ MikroTik]>: put (1. 3) + 1)
14
[Admin @ MikroTik]>: set a "It's"
[Admin @ MikroTik]>: put ($ a. OK)
It's OK

ROS script Reserved Words
Beep execute global list pick time toip typeof
Delay find if local put toarray tonum while
Do for led log resolve tobool tostr
Environment foreach len nothing set toid totime

: Beep length = 2 s frequency = 10000
Generates 2 seconds of 10 kHz audio
The default value of length is 100 ms.
Frequency defaults to 1000Hz

: Set a "/int dis lan \ n/int dis wan"
: Execute $
Execute multiple commands. In this example, two commands are executed. \ N is a line feed.

: Global
Define global variables

: List interface
Display related commands. Display the interface commands in the current directory and subdirectory

: Pick
Take a break from a string or array. The first string (array) is 0.
[Admin @ MikroTik]>: put [: pick "I love you" 2 6]
Love

: Time
Time required to execute the command
[Admin @ MikroTik]>: put [: time [: resole www.sina.com.cn]
00:00:00. 006
Time required to resolve the domain name www.sina.com.cn

Toip toarray tonum tobool tostr toid totime
Conversion Value Type

: Delay 3
Delay: 3 seconds. The default value is 1 second.

: Find
Searches for the first position in a string or array where the search content appears.
[Admin @ MikroTik]>: put [: find abcdcba cd]
2
[Admin @ MikroTik]>: put [: find "1, 2, 3, 3, 2, 1" 2]
1

: Put
Output to the screen. There are many examples above.

: If
Condition Selection
[Admin @ MikroTik]>: if (1 <2) do = {: put true}
True
If the condition is true, run the command in do = {}.
[Admin @ MikroTik]>: if (1> 2) do = {: put true} else = {: put flase}
Flase
If the condition is true, run the command in do = {}; otherwise, run the command in else = {}.

: Local
Define local variables

: While
Execute the script command in do ={} cyclically when the condition is true.
[Admin @ MikroTik]>: set I 0;: while ($ I <5) do = {: put $ I;: set I ($ I + 1 )}
0
1
2
3
4
5

:
Execute the script command in do ={} cyclically
: For I from = 1 to = 100 step = 30 do = {: put $ I}
1
31
61
91

: Foreach
Execute the script command in do ={} cyclically in the collection (array ).
: Foreach I in = [/interface find type = ether] do = {: put [/interface get $ I name]}
Ether1
Et22.
Ether3
Ether4
Output cyclically in the set of [/interface find type = ether] (interface ID of the ether type)

The name of the interface. I have four NICs.

: Log Content
Write text to log (script log)
Type can be found in/system logging
: Log info "system information"
Check the running result in the LOG.

: Resolve
IP address of the resolved Domain Name
[Admin @ MikroTik]>: put [: resolve www.sina.com.cn]
61.172.201.240

: Environment print
Show all variables and their values

: Len
Length of a string or Array
[Admin @ MikroTik]>: put [: len hello]
5
[Admin @ MikroTik]>: put [: len ","]
6

: Nothing
Null Value. The value of nothing ranges from 0 to not null ""
: The result of finding abc a is 0.
: Find abc d. The result is nothing.

: Set
Assignment
[Admin @ MikroTik]>: set a test
Assign the abc character to variable
[Admin @ MikroTik]>: put $
Test
[Admin @ MikroTik]>: put
A
The value of the referenced variable must be prefixed with $
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.