Script "... find where !routing-mark" stops work routerOS6.7

Hi,
I need to get the default route (0.0.0.0/0), from 3 entries, that have no routing-mark. In earlier versions of routerOS the bellow command was working fine:

:put [/ip route find dst-address=0.0.0.0/0 !routing-mark]
<<<< in version 6.7 you can see the answer is blank, i.e., no macth
:put [/ip route find dst-address=0.0.0.0/0]
*15e;*204;*1 <<< 3 routes match

:foreach b in=[/ip route find where dst-address=0.0.0.0/0] do={ :put (“$b”,[/ip route get $b routing-mark],“—”)};
*15e;ft;—
*204;Gazola;—
*1;— <<< There is no routing-mark in route-id “*1” you can see in bellow print command output.

:put [/ip route find dst-address=0.0.0.0/0 routing-mark!=“”] #routes with routing-mark NOT blank
*15e;*204 <<< this comand works and list only routes that have some routing-mark, its opposite should list “id=*1” but dont work

:put [/ip route find dst-address=0.0.0.0/0 routing-mark=“”]
<<< answer is blank, i.e., no macth. Has version 6.7 a bug.


Thanks,
Daniel


---- route print comand output
:put [/ip route print where dst-address=0.0.0.0/0]
0 A S ;;; dst-address=0.0.0.0/0 gateway=x.x.x.x gateway-status=x.x.x.x reachable distance=1 scope=30 target-scope=10 routing-mark=ft
1 A S ;;; dst-address=0.0.0.0/0 gateway=x.x.x.x gateway-status=x.x.x.x reachable distance=1 scope=30 target-scope=10 routing-mark=Gazola
2 A S ;;; dst-address=0.0.0.0/0 gateway=x.x.x.x gateway-status=x.x.x.x reachable distance=1 scope=30 target-scope=10

The RouterOS has no support for command like isNil (or isNull)

remember: nil = nil always return false

Use that method for check routing mark (Tested myself on RouterOS 6.7):

/ip route
:foreach route in=[find] do={
    :local mark [get $route routing-mark]
    :if ([:typeof $mark] = "nil")  do={
        :put "no routing-mark"
    } else={
        :put "has routing-mark $mark"
    }
}

Try this:

:put [/ip route find dst-address=0.0.0.0/0 !routing-mark~""]

:slight_smile: Karma = “Thank You”

~ are for bit inversion :frowning:

use my example, or in short if you want the solution without thinking :sunglasses: :

:put [/ip route find dst-address=0.0.0.0/0 (routing-mark)."" = ""]

:laughing:

Only when used with numbers! :
bit.JPG
But if you use it with strings it works different:
string.JPG
Source: http://wiki.mikrotik.com/wiki/Manual:Scripting#Operators

My example just works.

The empty routing-mark is “nil” not a string, ip address, or number.

In RouterOS is missing isNil function

Generally:

(!nil) = nil (fixed on 6.7, before 6.7 = false)
(nil = “”) = false
(nil != “”) = true
(nil = nil) = false !!!
(nil != nil) = true !!!
nil + nil != nil
nil + “” = “”
using ~ to a nil variable must be result nil, not “” (as !nil fixed)

In future RouterOS “~” can be fixed as “!routing-mark” and your method stop working.

In future RouterOS everything can stop working. :wink: I think they will not change it back to state v6.6 so any other way that works is good. I tested your method and it works also, so… thanks for another alternative! :slight_smile: