Community discussions

MikroTik App
 
TroyQ
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Thu Oct 20, 2016 10:02 pm

How to find certain CAPS with FIND WHERE command

Thu Jun 02, 2022 9:47 am

Hi Guys

I need to use the find where command in a script.
I am trying to write a script where I need to turn off a guest wifi in my my CAPS-MAN at certain times.
I have over 90 CAPS and I only need to turn off only the ones where the names start with BTH. (examples: BTH indoor, BTH Outdoor, BTH room1, BTH corner, etc....)

for this example I am using print where just to test it.
this is how far I got but it is not working...
 /caps-man radio> print where REMOTE-CAP-IDENTITY={BTH}
Don't worry about the rest of the script, that part is working when I use the full syntax in the Terminal. I just need to get the FIND WHERE part working

Please assist, I know this forum always comes through.
Thanks
TroyQ
 
afuchs
Frequent Visitor
Frequent Visitor
Posts: 81
Joined: Wed Jul 03, 2019 11:10 am

Re: How to find certain CAPS with FIND WHERE command

Thu Jun 02, 2022 11:50 am

For exact match
 /caps-man radio> print where REMOTE-CAP-IDENTITY="BTH"

For regex match
 /caps-man radio> print where REMOTE-CAP-IDENTITY~"BTH"
 
TroyQ
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Thu Oct 20, 2016 10:02 pm

Re: How to find certain CAPS with FIND WHERE command

Thu Jun 02, 2022 4:03 pm

Thank you for the quick response.
It did not work either.
1.jpg
As you can see no results...but print shows all the AP's
2.jpg
Hope this helps.
Thanks
You do not have the required permissions to view the files attached to this post.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12554
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: How to find certain CAPS with FIND WHERE command  [SOLVED]

Thu Jun 02, 2022 4:28 pm

@TroyQ, @afuchs doesn't bring anything, don't waste your time.

# for print
/caps-man radio print where remote-cap-identity~"^BTH"

# for script simlpy replace "enable" with "disable" when needed
:foreach radio in=[/caps-man radio print as-value where remote-cap-identity~"^BTH"] do={
    :local mac (($radio)->"radio-mac")
    /caps-man interface enable [find where radio-mac=$mac]
}

But... what you want exactly do?
Disable / Enable all radio that have "BTH" at the start of radio name?

Probably you need ONLY THIS instead, is more simpler and linear:
/caps-man interface disable [find where radio-name~"^BTH"]


/caps-man interface enable [find where radio-name~"^BTH"]
 
TroyQ
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Thu Oct 20, 2016 10:02 pm

Re: How to find certain CAPS with FIND WHERE command

Fri Jun 03, 2022 12:25 pm

Thank you! @rextended
You are a genius! :D
I just needed to turn the students WiFi off at night and leave the Faculty WiFi on.
This is what I ended up with using a script in scheduler:

This turns it off in the evening
/caps-man provisioning 
set slave-configurations="" [find where comment~"^BTH"]
/caps-man radio 
provision [find where remote-cap-identity~"^BTH"]


and this turns it back on in the morning
/caps-man provisioning 
set slave-configurations="BTH Leerders" [find where comment~"^BTH"]
/caps-man radio 
provision [find where remote-cap-identity~"^BTH"]
Thanks again!!! :mrgreen:

Who is online

Users browsing this forum: No registered users and 10 guests