Community discussions

MikroTik App
 
zivtal
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 57
Joined: Sun Feb 05, 2017 6:22 pm

Search mangle by command contain script...

Fri Feb 09, 2018 10:52 pm

Hi,

I have several mangles that contain the work "incoming from" in his comment (for example: "prerouting incoming from 'eth08client' outgoing to 'bridge-local'"), I would like to remove all [/ip firewall mangle] that contain the works "incoming from" in comment... there is a way to do it with foreach ?
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: Search mangle by command contain script...

Sat Feb 10, 2018 12:20 pm

There is, but you don't have to use foreach at all. You can just use "find" to match the correct items:
/ip firewall mangle remove [find where comment~="incoming from"]
The "find" gets you IDs of all items that contain "incoming from" in comment, and "remove" then removes all of the matched IDs in one go.
 
zivtal
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 57
Joined: Sun Feb 05, 2017 6:22 pm

Re: Search mangle by command contain script...

Sat Feb 10, 2018 3:57 pm

Just check it and got an error :/

"missing value for where (line 1 column 48)"
There is, but you don't have to use foreach at all. You can just use "find" to match the correct items:
/ip firewall mangle remove [find where comment~="incoming from"]
The "find" gets you IDs of all items that contain "incoming from" in comment, and "remove" then removes all of the matched IDs in one go.
 
User avatar
mohmadtnnari
just joined
Posts: 9
Joined: Sun Jan 17, 2016 11:46 pm
Location: syria-idleb
Contact:

Re: Search mangle by command contain script...

Sun Feb 11, 2018 2:31 pm

fix Roll
/ip firewall mangle remove [find where comment="incoming from"]
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: Search mangle by command contain script...

Sun Feb 11, 2018 5:48 pm

Just check it and got an error :/

"missing value for where (line 1 column 48)"
Oops... Sorry... It's been a while since I've used the regex operator... It's
/ip firewall mangle remove [find where comment=~"incoming from"]
(the "~" is AFTER the "=", not before)
fix Roll
/ip firewall mangle remove [find where comment="incoming from"]
Without the "~", you'd get items where the whole comment says "incoming from", not a comment that has "incoming from" somewhere within it.
 
zivtal
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 57
Joined: Sun Feb 05, 2017 6:22 pm

Re: Search mangle by command contain script...

Sun Feb 11, 2018 9:55 pm

Thanks!

Who is online

Users browsing this forum: No registered users and 29 guests