false positive check doesnt work

Hello guys,

i have a question regarding a script,
if i run the script by terminal it works fine, even with “/system script run …”

but if i let the script run by netwatch, it doesn’t


this is the script i have created:

:log warning message="Start failover check - check ping"
:global ping
:set $ping [/ping 192.168.100.1 count=10]

/do { 
:log warning message="If ping = 0 run down script"
:if ($ping = 0) do={

:log warning message="Put FO to 0"
:global FO 0

:log warning message="sending SMS"
/tool sms send phone-number=NUMBER message="Sint-Rembert: Standaard gateway is DOWN, LTE is FAILOVER" port=lte1

:log warning message="Finished part - down script"
} else={:log warning message="ping is NOT 0 - up or unstable"}

:log warning message="If ping = 10 and FO = 0 run up script"
:if ($ping = 10 & $FO = 0) do={

:log warning message="Put FO to 1"
:global FO 1

:log warning message="sending SMS"
/tool sms send phone-number=NUMBER message="Sint-Rembert: Standaard gateway is UP, LTE is standby" port=lte1

:log warning message="Finished part - up script"
} else={:log warning message="ping is NOT 10 - Down or unstable"}

:log warning message="Remove conections"
/ip firewall connection remove [find]

:log warning message="Finished failover script"
}

what does it do:
this is a scrip in a wap LTE kit, t
the script checks if the main router is active or not,

  1. if the main switches to failover and uses the Mobile data of the wap LTE kit the wap sends a sms to a provided number. to tell me its switched over.
  2. if after a switch or “down” the main switches back or goes "up"to the main gateway of the ISP the LTE sends a sms to tell it switched back to the main ISP
  3. because there are some switches in between that we don’t manage, it hapens that we have some timeouts on ping, so there is also a system the kills out these false positive UP’s, since every up sends us an SMS after a ping loss

everything works fine exept if i add the false positive check it doesn’t work at all. it doesnt create globals and it doesn’t check them even if i add them manualy,
if i do it by terminal it all works fine for some reason.

my network setup looks as follows
https://www.dropbox.com/s/ur3ce2tb915y293/Schermafbeelding%202020-01-06%20om%2016.59.09.png?dl=0

any ideas what goes wrong?

You copy paste the whole scipt in netwatch ? Thats what you mean ?

Hello Zacharias

No, i use Netwatch to run the script in Scripts

in netwatch i just do /system script run SCRIPTNAME