Hotspot Script Match Assistance

Hi All,

We are attempting to create a script that :

Deletes all queues where

  1. Name contains the word “hotspot” AND
  2. IP Address NOT in a specified subnet

The first part works with the name, but we can’t seem to get the IP Address section to work.

here is our code:

/queue simple {
:foreach item in=[find name ~“hotspot” && target in !=“1.1.1.0/24”] do={
remove $item
}
}

Here is the queue that should be deleted :
[admin@MikroTik] /queue simple> pr
Flags: X - disabled, I - invalid, D - dynamic
0 name=“hotspot” target=2.2.2.2/32 parent=none packet-marks=“” priority=8/8 queue=default-small/default-small limit-at=0/0 max-limit=0/0
burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s bucket-size=0.1/0.1


Can someone assist please? Thank You

:foreach item in=[/queue simple find where (name~"hotspot" && target!="1.1.1.0/24")] do={/queue simple remove $item}

Thank You for the assistance.

The code provided matches anything that is not specifically “1.1.1.0/24” but does not actually check to see if the IP Address is not in that range.

Example : the script provided will remove a queue with the target IP of 1.1.1.2 which it should not.

:foreach item in=[/queue simple find where (name~"hotspot" && target~"1\\.1\\.1\\.[0-9]+"=false)] do={/queue simple remove $item}