Community discussions

MikroTik App
 
lashguti
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Sat Apr 21, 2012 7:42 am

where is an error here

Sat Jul 12, 2014 11:21 pm

: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
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: where is an error here

Sat Jul 12, 2014 11:46 pm

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={
 
lashguti
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Sat Apr 21, 2012 7:42 am

Re: where is an error here

Sun Jul 13, 2014 6:45 am

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
 
lashguti
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Sat Apr 21, 2012 7:42 am

Re: where is an error here

Sun Jul 13, 2014 9:11 am

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];

}
 
User avatar
Etz
Member Candidate
Member Candidate
Posts: 178
Joined: Thu Mar 27, 2014 10:09 am
Location: Estonia

Re: where is an error here

Sun Jul 13, 2014 9:25 am

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...
 
lashguti
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Sat Apr 21, 2012 7:42 am

Re: where is an error here

Sun Jul 13, 2014 9:42 am

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 " ; "

Who is online

Users browsing this forum: No registered users and 46 guests