Script not workin when schedulled, but work in terminal
Posted: Tue May 24, 2016 3:47 pm
Hi,
I have two scripts, one to update the default gateway e other to ping in default gateway and reboot case the timeout excedds 60.But the timeout script not workin when is schedulled.
Gateway script
Netwatch script (adapted from wiki)
Tested in versions 6.13 ,6.24 and 6.34.2.
I have two scripts, one to update the default gateway e other to ping in default gateway and reboot case the timeout excedds 60.But the timeout script not workin when is schedulled.
Gateway script
Code: Select all
:global defGateway;:foreach i in=[/ip route find] do={:if ([:typeof [:find [/ip route get $i active] yes]]!="nil" && [:typeof [:find [/ip route get $i dst-address] 0.0.0.0/0 ]]!="nil" ) do={:set defGateway [/ip route get $i gateway]; }}
Code: Select all
:global i 0; {:do {:set i ($i + 1)} while (($i < 60) && ([/ping $defGateway interval=5 count=1]=0))};:if ($i=60 ) do={:log info "Reboot devido ao Netwatch" ;delay 3s; :foreach i in=[/user find] do={:if ([:typeof [:find [/user get $i name] "infra"]]!="nil") do={/user enable $i }} ;/sys reboot};