Can I use if after else?
if (safsafasfasfasfasfa);
else:
if(safasfsafasfasf)
or its not possible in Mikrotik scripting?
Yes you can use as many if and else you like.
Example
:if (version>=6.5) do={
# Do some stuff
} else={
# Do some other stuff
:if (host=27) do={
# Do some other stuff here
}
}
Thanks, just another question is the syntax ok if I want to ping host A and B and both are down switch of C
:if ([/ping 10.10.200.1 count=5] AND [/ping 10.10.100.1 count=5] = 0) do={[/interface disable ether8]} this line doesn work its switches off ether if one or other is down
and if A or B is accessible switch C back online
:if ([/ping 10.10.200.1 count=5] | [/ping 10.10.100.1 count=5] != 0) do={[/interface enable ether8]} this line works perfect
Script can be used to nearly all tings, but do not use ping to test for ip up, use netwatch.
https://wiki.mikrotik.com/wiki/Manual:Tools/Netwatch
Do search forum here for example
yeh i understand but i want to test two host instead of one before taking some action
Then you just use and &&
:if ($test1="true"&&test2="true") do={
# do some here
}
PS no need to quote the whole post above your. Use Post Reply button at the bottom of the post
Jotne thank you, this worked like a charm no I have a simple script with two hosts check-up and different do scenarios, I really appreciate your advice’s.