Where can I get information about scripting in mt3, syntax etc..?
Syntax is almost the same as 2.9.
Biggest difference is that you have to declare variables before usage.
well.. okay, and what about “)” etc?
:if ([/system package get [/system package find name=ntp ] name]=“ntp” ) do=[:log warning “ntp package passed”]
I had it fine on 2.9
But 3.0 returns me - expected command name line 1 column 1.
what do you mean about “)” ?
Things you should know about 3.0:
- don’t use . for concat, use:
:global sss 23;
:put ("sss=$sss);
- don’t use after do= they are still there only for compability, use:
:if(true) do={ ... };
- If it is string then put it in ", otherwise it could cause some issues.
- some other things that I can’t remember right now
btw your example works for me.
well, i suppose I should disable IPv6 support, cause it makes some difficulties by importing something like “/ip firewall add-chain”
- also i had such string:
/ip address find network=networkip disabled=no
but 3.0rc9 doesn’t like this disabled=no, what is the analog of this propery?
Read RC9 changelog
now logical operators ‘&&’ and ‘||’ can also be written as ‘and’ and ‘or’;
removed ‘where’ and ‘from’ arguments of find command. now find command
can be followed by arbitrary expression that can use item properties,
e.g. “find dst-address in 192.168.0.0/16 and interface=wlan1”;
So it means that find parameters are treated as expressions, now correct syntax would be, for example:
/ip address find interface=ether1 && disabled=no
okay thanks ![]()
but i have one more question:
in 2.9 we had set-nexthop
in 3.0 we have set-in-nexthop, set-out-nexthop , set-in-dexthop-direct etc..
can i know about all these feautures, and what is similar to set-nexthop in v2.9?
add name=“limit-disable” on-event={/queue tree disable DL_16_52;/queue tree disable UL_16_52;/queue tree disable DL_11_80;/queue tree disable UL_11_80} start-date=jun/16/2006 start-time=00:55:00 interval=1d
he doesn’t like “{” after on-event= . I’ve tried to use [ instead , but then ONEVENT section in imported sheduler rule is empty. What should I use?
of course it will do that. As i mentioned earlier when you write a string put in quotes.
on-event="{/queue tree disable DL_16_52;/queue tree disable UL_16_52;/queue tree disable DL_11_80;/queue tree disable UL_11_80} "
add name=“dolg_enable” on-event=“{:foreach n in=[/ip firewall nat find comment=DOLG disabled=yes ] do=[/ip firewall nat set $n disabled=no];:foreach n in=[/ip firewall filter find chain=forward comment=DOLG] do=[/ip firewall filter enable $n]}” start-time=17:33:00 interval=25m start-date=Jan/01/1970
he doesn’t understand $n
[admin@mikrotik] /system scheduler> add name=“dolg_enable” on-event=“{:foreach n in=[/ip firewall nat find comment=DOLG disabled=yes ] do={/ip firewall nat set
$n disabled=no};:foreach n in=[/ip firewall filter find chain=forward comment=DOLG] do={/ip firewall filter enable $n}}” start-time=17:33:00 interval=25m sta
rt-date=Jan/01/1970
expected end of command (line 1 column 125)
i’m going crazy with this script ![]()
$ is special character, to include it in string put \ before symbol.
yes, okay, but then he doesn’t understand DISABLE=no after that $n. m?
and the second and the last question - why does he return me that end of command expected. Have I forgotten some brace? I can’t find where.
Another thing i noticed is that the syntax to add a tos chain has also changed. Or basicaly just the tos name.
“set $n disabled=no” is recognized correctly, just type " at the end.
Just fix your errors and command will be recognized. Put \ before every $.
[admin@mikrotik] /system scheduler> add name=“dolg_enable” on-event=“{:foreach n in=[/ip firewall nat find comment=DOLG disabled=yes ] do={/ip firewall nat set
$n disabled=no};:foreach n in=[/ip firewall filter find chain=forward comment=DOLG] do={/ip firewall filter enable $n}}” start-time=17:33:00 interval=25m sta
rt-date=Jan/01/1970
expected end of command (line 1 column 125)
is there no mistakes in braces before :foreach?
okay , thanks
DOH!!
NO, there are no mistakes before :foreach
I’m telling you the third time, PUT \ before all $ characters you have and you will not have an error.