script-help

:if ( [/ping 192.x.y.z ] = 0) do={/interface ethernet cable-test ether2 duration=3}

how can i get result on that on the log, rather than waiting on the terminal for this to happen?

You can use /tool/netwatch instead**, then in the “On Down”, do something like this:
/log info [/interface ethernet cable-test ether2 duration=3 as-value]

**Not sure your if statement with the “:if [/ping 192.168.88.1]” is correct/works, thus suggesting netwatch since it can periodically do the ping for you (and run your cable test if the down). If you use the “:if ([ping])…”, then do={} part is same as above to log the results of cable test.

i was thinking something else, but your solutions will do what i am expecting

I only suggested netwatch since scripting “:ping” isn’t so simple. But you can do it, just not a simple “if” since you specify the # of time you want to ping etc. and then have to parse the results. Netwatch wraps that all up for you.

But the basics of using ping is you need an “as-value” to say to return the data (not output to screen) and a count:

:put [/ping 192.168.74.1 as-value count=10]

If really just one ping, in a standalone script, you could do that:

:if ([/ping 192.168.88.1 as-value count=1]->"status" != "timeout") do={
   /log info [/interface ethernet cable-test ether2 duration=3 as-value]
}

But the above get more complex if you care want to take an action if take a long time, or after X number of failed pings, etc. etc.

i think the one above is better, the last one that u posted doesn’t work on log:
log.PNG

Sorry, the “as-value” is what’s important – I was typing it without testing it. I fixed the example above.
/log info [/interface ethernet cable-test ether2 duration=3 as-value]

@nichky is for v6 or v7? Syntax change…

On what hardware? ethernet check do not work on same way on all devices…

Why check 3 times and not only “once”? The result is always the last cable check…

for v6

{
    :local tip 192.168.88.1
    :local tif "ether2"
    :if ([:ping address=$tip count=1] = 0) do={
        :local test [/interface ethernet cable-test $tif once as-value]
        :if (($test->"status") = "link-ok") do={
            :log warning "reply from $tip NOT received, but the link on $tif appear to be OK"
        } else={
            :local tcap [:tostr ($test->"cable-pairs")]
            :log warning "reply from $tip NOT received, and there is NO link on $tif [$tcap]"
        }
    } else={
        :log info "reply from $tip received"
    }
}

for v7

{
    :local tip 192.168.88.1
    :local tif "ether2"
    :if ([:typeof ([:ping address=$tip count=1 as-value]->"time")] = "nothing") do={
        :local test [/interface ethernet cable-test $tif once as-value]
        :if (($test->"status") = "link-ok") do={
            :log warning "reply from $tip NOT received, but the link on $tif appear to be OK"
        } else={
            :local tcap [:tostr ($test->"cable-pairs")]
            :log warning "reply from $tip NOT received, and there is NO link on $tif [$tcap]"
        }
    } else={
        :log info "reply from $tip received"
    }
}

both script can be altered, for example, for warn if for 10 ping the reply are less (= unstable), or not reply at all (= ureachable)

three point basket