script working in scripting won't work in netwatch, not a permission issue

:local HOST "192.168.1.1"
:local PINGCOUNT "10"
:local INTF "sfp-sfpplus1"
:local DELAY "3s"
:delay 10s
:if ([/ping $HOST interval=1 count=$PINGCOUNT] = 0) do={
:log error "Interface $INTF is down, restarting..."
/interface ethernet set $INTF auto-negotiation=no
:delay $DELAY
/interface ethernet set $INTF auto-negotiation=yes
:log warning "$INTF restart complete."
} else={
:log info "$INTF is working.";
}

Above works in scripting and scheduler



:local INTF "sfp-sfpplus1"
:local DELAY "3s"
:log error "Interface $INTF is down, restarting..."
/interface ethernet set $INTF auto-negotiation=no
:delay $DELAY
/interface ethernet set $INTF auto-negotiation=yes
:log warning "$INTF restart complete."

These lines won’t work in Netwatch, and I don’t know why.
Only seen “Interface sfp-sfpplus1 is down, restarting…” in logging.
RB5009 RouterOS 7.2

Oh, I need to delete the space after “do”

Why not use netwatch function?
Its created for just this type of senarios.

I didn’t know that, will look it up later.
Thank you.



:local INTF "sfp-sfpplus1"
:local DELAY "3s"
:log error "Interface $INTF is down, restarting..."
/interface ethernet set $INTF auto-negotiation=no
:delay $DELAY
/interface ethernet set $INTF auto-negotiation=yes
:log warning "$INTF restart complete."

These lines won’t work in Netwatch, and I don’t know why.
Only seen “Interface sfp-sfpplus1 is down, restarting…” in logging.