Community discussions

 
sergefonkou
just joined
Topic Author
Posts: 1
Joined: Thu Oct 03, 2013 3:55 pm

string comparaition

Tue Jul 30, 2019 9:31 pm

hi,
please, I don't really understand why this script is not working when making comparaison to switch on sim-slot, it's seems mikrotik don't compare string values !!! Please help ?

:local simlte [/system routerboard sim get value-name=sim-slot]
:if ($PingFailCountLTE >= $FailTreshold) do={
:if ($PingFailCountLTE >= 100) do={
:set PingFailCountLTE 100
}
:if ( $simlte != "b"){
/system routerboard sim set sim-slot=b;
/log warning " etat du port lte va changer à : $simlte"
delay 60s;
};
}
:if ($PingFailCountLTE < $FailTreshold) do={

:if ( $simlte != "a"){
/system routerboard sim set sim-slot=a;
/log warning " etat du port lte va changer à : $simlte"
delay 60s;
};
}
 
gbudny
just joined
Posts: 12
Joined: Tue Feb 09, 2016 10:57 am
Location: Poland, Katowice

Re: string comparaition

Fri Aug 09, 2019 6:15 pm

Hey,

RouterOS does support String comparison ;)
There are few bugs in the script so maybe that is why it is not working.
Remember to put proper construction of :if statement. There are missing "do=" syntax. proper syntax is :if (sth) do={} else={}
delay command must be followed by ":" so :delay time_in_secs is proper syntax.
Once combining plain text with variable into 1 string put it inside brackets in the following manner: :log info ("test notification number: ".$variable);

I hope it will help a bit ;)
Best Regards
Grzegorz Budny
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1296
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

Re: string comparaition

Fri Aug 09, 2019 6:58 pm

You do not need semicolon at end of each line ; , only when multiple commands on same line.

Use this to see what type your variable is.
:put [:typeof $myStr]
It its not string, you can force it to string.
:if ([:tostr $myStr] = "something") do={:put "yes"}
 
How to use Splunk to monitor your MikroTik Router

MikroTik->Splunk
 

Who is online

Users browsing this forum: No registered users and 10 guests