Using variables to find comments - Not working

Hi all, to make my scripts a little neater it would be great if I could save a comment in a local/global variable. However, I’ve tried this is in the shell and it doesn’t work as planned.

If I store the comment I need to find in a variable, when using it with a find, it brings back several results instead of the one I expect.

Ive included a demonstration below-
[admin@Leicester] > / ip route add dst-address=192.168.14.2 gateway=ETH03 comment=“Hello”
[admin@Leicester] > :global comment “Hello”
[admin@Leicester] > :put [ip route find comment=$comment]
*13;*1b;*1e;*1a
[admin@Leicester] > :put [ip route find comment=Hello]
*1eAny help appreciated, Thanks.

[admin@r1] /ip route> add gateway=1.1.1.1 comment=lala
[admin@r1] /ip route> :put [find comment=lala]
*d
[admin@r1] /ip route> :global comment “lala”
[admin@r1] /ip route> :put [find comment=$comment]
*dWorks perfectly fine with latest ROS.

Did you use 6.10? I’m using 6.7, I re-tested and I’m still having issues. I’m hesitant to upgrade to 6.10 as it was crashing on me, but if this is a bug that has been identified and fixed by Mikrotik I guess I will have to wait for 6.11.

When testing, did you have other routes with comments?
[admin@Leicester] /ip route> add dst-address=192.168.168.0/24 gateway=1.1.1.1 comment=lala
[admin@Leicester] /ip route> :put [find comment=lala]
*20
[admin@Leicester] /ip route> :global comment “lala”
[admin@Leicester] /ip route> :put [find comment=$comment]
*13;*1b;*1a;*20

@marrold
Tested on v.6.10, your code returns IDs of all routes with comment, not only one with specific comment (e.g. ‘lala’).
You are right, it’s probably ROS bug.

Regards,

Thanks for testing and confirming it’s not just me!

Ok found the problem. Do not use variable name the same as property names, since in some situations property also can be used as built in variable.

DST-ADDRESS PREF-SRC GATEWAY DISTANCE

0 A S 0.0.0.0/0 10.5.101.1 1
1 A S ;;; lalal
1.1.1.1/32 10.5.101.1 1
2 A S 2.2.2.2/32 10.5.101.1 1
3 A S ;;; bbb
3.3.3.3/32 10.5.101.1 1

[admin@r3] /ip route> :global myComment "lalal"
[admin@r3] /ip route> :put [find comment=$myComment]
*e