How to use [:nothing]?

Hello,

I am trying to do a check on DHCP-CLIENT like so:

:if ([/ip dhcp-client get [find interface=ether3] gateway != [:nothing]) do={:put “hi”;} else={:put “bye”};

However, when ether 3 has a gateway and when ether3 does not have a gateway the result is the same. Instead of [:nothing], I also tried " " and that didn’t work either..

I’m trying to determine if ether3 has a gateway or not and do something based on the result…


Thanks!

In recent RouterOS versions, you can use the “any” operator to check if a property is set (i.e. has a value, rather than “nothing”) as part of “where” expressions in “find” or “print”.

Since you want to check a particular item, I suggest a print with “count-only” and an appropriate expression.

So f.e.

:if ([/ip dhcp-client print count-only where interface=ether3 && any gateway] != 0) do={:put "hi";} else={:put "bye"};