A
A
Anton Kolisnyk2019-04-05 10:44:05
Mikrotik
Anton Kolisnyk, 2019-04-05 10:44:05

How to execute multiple commands in a row in mikrotik script?

I am writing a script that sends a notification to the mail when the route changes, but only the first command is always executed. What could be the problem?

/ip route set [/ip route find dst-address=0.0.0.0/0] gateway=99.99.99.99
/tool ​​e-mail send server=192.168.1.1 port=25 [email protected] password=PASSWORD to= [email protected] from="ROBOT" \
subject="MikroTik: $[/system clock get date], $[/system clock get time]" \
body="MAIN CHANNEL\nDate: $[/system clock get date ]\nATime: $[/system clock get time]";

Separately and together through the console commands are executed.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Parkhomenko, 2019-04-05
@Noklif

It's like in the Linux terminal:
If the commands must be run in turn, then at the end of each command you need to put a semicolon ";"
If you need dependent command execution, then you need to put "$$" or "||", which means logical AND and OR.
If you need simultaneous execution of commands, then a single "&" is placed at the end.

D
Dmitry, 2019-04-05
@Tabletko

Are you copying from somewhere? Apparently screw line breaks do not digest. Everything after the second command should be one line.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question