Page 1 of 1

Does find command distinguish small and capital letters

Posted: Sat Sep 01, 2018 3:19 pm
by ros44
Am I doing something wrong with the find command or this is how it works?

Example 1: Here the find command works as expected. It removes an interface from an interface list, based on interface id
/interface list member remove [ find interface=*f00020 ]
* the interface id starts with a small letter)

Example 2. Here find is used in a script and it doesn't work:
[admin@MyRouter] > :global MyVar;
[admin@MyRouter] > :set $MyVar "*f00019";
[admin@MyRouter] > /interface list member remove [ find interface=$MyVar ]

The solution is to change the small letter in the beginning of the interface id to capital one:

[admin@MyRouter] > :global MyVar;
[admin@MyRouter] > :set $MyVar "*F00019";
[admin@MyRouter] > /interface list member remove [ find interface=$MyVar ]

Additionally the IDs all interface list members are starting with capital letter. My question is how it works in example 1 and not in example 2.

[admin@MyRouter] > /interface list member print 
Flags: X - disabled, D - dynamic 
 #   LIST            INTERFACE
1   CUSTOM_LIST_01           *F00019
2   CUSTOM_LIST_01           *F0001A
3   CUSTOM_LIST_01           *F0001D
4   CUSTOM_LIST_01           *F0001E

Re: Does find command distinguish small and capital letters

Posted: Sat Sep 01, 2018 3:46 pm
by ADahi
Do not confuse Interface name with Interface id

Re: Does find command distinguish small and capital letters

Posted: Sun Sep 02, 2018 12:12 am
by ros44
Thank you for taking time to reply to my question.

I am talking about interface id. When used in terminal command find works well no matter if the interface id starts with capital or small letter. When used in a script it requires only capital letters. This is my problem.

Re: Does find command distinguish small and capital letters

Posted: Mon Sep 03, 2018 11:13 am
by ADahi
my router output
6.40.9 bugfix
/interface list member print 
Flags: X - disabled, D - dynamic 
 #   LIST                                                                INTERFACE                                                              
 0   test                                                                ether3                                                                 
 1   test                                                                ether4                                                                 
 2   test                                                                ether5                                                                 


Re: Does find command distinguish small and capital letters

Posted: Mon Sep 03, 2018 11:44 am
by ros44
Do you have any ppp interfaces? Can you add manually via winbox an interface to a test list. Then disconnect the interface and show a /interface list member print.

Re: Does find command distinguish small and capital letters

Posted: Mon Sep 03, 2018 2:04 pm
by ADahi
this mean interface deleted and shown as unknown interface

Re: Does find command distinguish small and capital letters  [SOLVED]

Posted: Mon Sep 03, 2018 4:55 pm
by ADahi
for delete "unknown" interface from list use
/interface list member remove numbers=[ find where list=test && interface~("^\\*[A-Z]+") ]

Re: Does find command distinguish small and capital letters

Posted: Tue Sep 04, 2018 6:05 am
by ADahi
or use this instead

Re: Does find command distinguish small and capital letters

Posted: Thu Sep 06, 2018 11:14 am
by ros44
I feel so lame. I spent hours on debugging a script to add/remove interfaces from a list your last post made me flash for a moment. It could have been so simple. Thank you.

Another way to do it was given to my by the support:

On-up:
:local interfaceName [/interface get $interface name]
/interface list member add interface=$interfaceName list=OPERATORS_IFs

On-down:
delay 1
:local interfaceName [:toid $interface]
/interface list member remove [find interface=$interfaceName]