I’m trying to debug a problem of a script that seems to work correctly when the router is already running, but does not seem to actually do anything when run in the scheduler on startup. I can see in
/system scheduler
that the run count has increased to 1 when I reboot the router but nothing else happens.
add comment="Enable WAN Netwatch on Reboot for Primary Router" name=\
netwatch-enable on-event="/system script run enable-wan-netwatch" policy=\
read,write,policy,test,password,sniff,sensitive start-time=startup
The script & scheduler policies seem to be identical and I have tried setting the on-event in the scheduler to just “enable-wan-netwatch” as well, but so far nothing works. Any help in figuring out what I’m doing wrong is very much welcomed!
Version info:
[] Router: CCR1009-8G-1S-1S+
[] ROS version: 6.48
Hello. Actually I want the script to keep looping when the interface is not available, hence the “while ($waniface != $wangateway)” check. But I’m not sure what is happening as the subsequent “/tool netwatch enable” command does not seem to run either.
Yes, I realised that this logic flaw and modified the while loop slightly. This is the new loop:
:while ($waniface != $wangateway) do={
#:nothing
:local waniface [/interface detect-internet state get [:pick [find state="internet"] 0] value-name=name]
}
However, in both case after the router reboot I do not see anything running in “/system scheduler jobs” which is strange.
That is frustrating. I am hoping to keep the script simple as it just needs to enable a netwatch check after the router gets a IP. I really would prefer to not have to write my own logic to check if network is available
Thanks for the recommendation eworm. I could not get it to work with the variable check and in fact even the “:set $variable” I had in the loop was not working correctly. Once I modified the script to use the :len check logic you provided, it started working correctly.
The other gotcha for me was I had the script/scheduler policy set to “read/write/policy/test” only but for netwatch commands to execute in a script, you need to add “reboot” Policy as well.