What am I missing?

Hi,

Running ROS v4.10

This script fails to log “Not Found” as it is desired.

{:if ([/interface wireless reg find mac-address=00:01:02:03:04:05] = 0) 
do={:if ([/interface wireless reg find mac-address=AA:AB:AA:AA:AA:AA] = 0)  
do={:log info "not found"}}}

What am I missing?

Cheers
Brian

Try this:

:if (:len [/int wir reg find mac-address=00:01:02:03:04:05] = 0) do={
    :if (:len [/int wir reg find mac-address=AA:AB:AA:AA:AA:AA] = 0) do={
        :log info "not found";
     }
}

I shortened things to fit on the correct line.

Hi Tim,

Tried it, no response at all, nothing logged. Those mac-addresses do not exist on my system, so it should log “not found”. This originally comes from http://www.mikrotik.com/testdocs/ros/2.8/appex/scripting1.php, so I am not sure if after numerous version changes, that coding still operates.

Thanks
Brian

My bad! I forgot the brackets around :len statement.

:if ([:len [/int wir reg find mac-address=00:01:02:03:04:05]] = 0) do={
    :if ([:len [/int wir reg find mac-address=AA:AB:AA:AA:AA:AA]] = 0) do={
        :log info "not found";
     }
}

EDIT: I moved brackets to correct position (only around :len[/int…], not around the “= 0”.

Thanks! that works perfectly now. Now I can work with that to monitor my backhaul links/failovers etc. Being a noob at scripting, it’s all trial an error for me, and only after at least 2 or 3 hours of failure, do I come here looking for help - need to do things myself so I can learn.

Regards
Brian

FYI: Those brackets “” mean “replace this statement with the value you get by executing this statement”. In your case, that would be the number of objects in the returned array, or “0”, because the mac is not in the list. Then it evaluates “0 = 0”, and that is “true”. So it runs the “do={}” statements.

Thanks Tim, have learned a bucket load today. Time to bump your karma up… :slight_smile:

Brian