Community discussions

MikroTik App
 
User avatar
jayd2k
newbie
Topic Author
Posts: 45
Joined: Tue Sep 10, 2013 6:46 am
Location: Philippines

[SOLVED] How to iterate only through interfaces that have a comment set?

Sat Feb 14, 2015 8:56 am

Hi,

I need a little help here - how to iterate through the list of interfaces that have a comment set?

Here's the list of interfaces I use for testing on an RB2011:
[admin@MikroTik] > interface print
Flags: D - dynamic, X - disabled, R - running, 
S - slave 
 #     NAME                                TYPE      
 0     ether1-gateway                      ether     
 1  RS ;;; test123
       ether2                              ether     
 2   S ether3                              ether     
 3   S ether4                              ether     
 4   S ether5                              ether     
 5   S ether6-master-local                 ether     
 6   S ether7-slave-local                  ether     
 7   S ether8-slave-local                  ether     
 8   S ether9-slave-local                  ether     
 9   S ether10-slave-local                 ether     
10   S sfp1                                ether     
11  R  bridge-local                        bridge
Trying to iterate only through interfaces that have a comment set:
[admin@MikroTik] > :foreach IF in=[/interface ethernet find where comment] do={ put $IF };
Using the negation operator I can at least get a list of interfaces which do not have any comment set:
[admin@MikroTik] > :foreach IF in=[/interface ethernet find where !comment] do={ put $IF };
*2 
*4
*5
*6
*7
*8
*9
*a
*b
*1
 
The expected result is to list only ether2 as it is the only interface with a comment.

Thanks
Last edited by jayd2k on Sat Feb 14, 2015 4:37 pm, edited 1 time in total.
By 2016 total internet traffic will be 3x 2011
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2411
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: How to iterate only through interfaces that have a comment set?

Sat Feb 14, 2015 3:12 pm

Since recent versions, I think you need to use "any", i.e.
find where any comment
PEAR2_Net_RouterOS(1.0.0b6) - My API client in PHP
(Rate my posts? If you want... no pressure...)
 
User avatar
jayd2k
newbie
Topic Author
Posts: 45
Joined: Tue Sep 10, 2013 6:46 am
Location: Philippines

[SOLVED] Re: How to iterate only through interfaces that have a comment set?

Sat Feb 14, 2015 4:36 pm

Since recent versions, I think you need to use "any", i.e.
find where any comment
Yes, that works. Thanks! Seems like the scripting guide in the wiki could use a little updating.
By 2016 total internet traffic will be 3x 2011
 
petrn
Member Candidate
Member Candidate
Posts: 179
Joined: Thu Jul 29, 2010 3:56 am

Re: How to iterate only through interfaces that have a comment set?

Sun Feb 15, 2015 3:23 pm

Since recent versions, I think you need to use "any", i.e.
find where any comment
I wonder where is documentation for this, can Mikrotik enlighten me?
Petr
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2411
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: How to iterate only through interfaces that have a comment set?

Sun Feb 15, 2015 4:14 pm

Since recent versions, I think you need to use "any", i.e.
find where any comment
I wonder where is documentation for this, can Mikrotik enlighten me?
It's in the change logs for 6.19, and only there for now.
PEAR2_Net_RouterOS(1.0.0b6) - My API client in PHP
(Rate my posts? If you want... no pressure...)

Who is online

Users browsing this forum: No registered users and 23 guests