Community discussions

MikroTik App
 
ros44
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 74
Joined: Sun Feb 25, 2018 2:05 am
Location: Sofia, Bulgaria

Does find command distinguish small and capital letters

Sat Sep 01, 2018 3:19 pm

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
Last edited by ros44 on Sun Sep 02, 2018 12:40 am, edited 1 time in total.
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: Does find command distinguish small and capital letters

Sat Sep 01, 2018 3:46 pm

Do not confuse Interface name with Interface id
 
ros44
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 74
Joined: Sun Feb 25, 2018 2:05 am
Location: Sofia, Bulgaria

Re: Does find command distinguish small and capital letters

Sun Sep 02, 2018 12:12 am

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.
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: Does find command distinguish small and capital letters

Mon Sep 03, 2018 11:13 am

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                                                                 

 
ros44
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 74
Joined: Sun Feb 25, 2018 2:05 am
Location: Sofia, Bulgaria

Re: Does find command distinguish small and capital letters

Mon Sep 03, 2018 11:44 am

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.
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: Does find command distinguish small and capital letters

Mon Sep 03, 2018 2:04 pm

this mean interface deleted and shown as unknown interface
You do not have the required permissions to view the files attached to this post.
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

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

Mon Sep 03, 2018 4:55 pm

for delete "unknown" interface from list use
/interface list member remove numbers=[ find where list=test && interface~("^\\*[A-Z]+") ]
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: Does find command distinguish small and capital letters

Tue Sep 04, 2018 6:05 am

or use this instead
You do not have the required permissions to view the files attached to this post.
 
ros44
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 74
Joined: Sun Feb 25, 2018 2:05 am
Location: Sofia, Bulgaria

Re: Does find command distinguish small and capital letters

Thu Sep 06, 2018 11:14 am

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]

Who is online

Users browsing this forum: No registered users and 22 guests