:global speed [/interface ethernet get 1 speed]
:if($speed != 1Gbps)do={
:log info speed
}
“if” statement is not matching, if I do :put $speed , it shows correct speed
:global speed [/interface ethernet get 1 speed]
:if($speed != 1Gbps)do={
:log info speed
}
“if” statement is not matching, if I do :put $speed , it shows correct speed
I don’t understand why, but for some reason, “1Gbps” or “100Mbps” (which is what I did tests with…) are not treated by the inequality operator as strings… despite being strings according to :typeof (as is the value of $speed).
You need to explicitly quote the “1Gbps” for the operator to recognize it as a string, i.e.
:if ($speed != "1Gbps") do={
Thanks for reply
I have tried that way too before I made first post:
:if($speed != “2Gbps”)do={
:log info speed;
}
but it does not match
I even tried:
:tostr $speed but nothing worked
I achieved the script to work,
but now I can’t run the script from scheduler, if I place script name in scheduler it says that it runs in scheduler but it does not run
in scripts menu
when I place script content directly into schedulers “on event” field it works fine, script itself works without scheduler too if press ‘run script’
interesting things are happening with routeros
Here is working script:
:global r
/interface ethernet monitor ether1 once do={
:set r $rate
}
:if ($r != “1Gbps”) do={
:log info “interface speed_not_gigabit”
[/interface ethernet disable ether1];
:delay 2;
[/interface ethernet enable ether1];
}
Its somekind of Winbox glitch, add script to scheduler from commandline after that you can adjust parameters from GUI.
AFAIK, something to do Sript and Scheduler permissions mismatch…
it was " ; "'s fault, which was needed at the end of each if script was called from scheduler,
if script was run directly then it worked fine without " ; "