Community discussions

MikroTik App
 
FRANKMUNOZAPURE
newbie
Topic Author
Posts: 28
Joined: Thu May 23, 2024 11:57 am

Remove mac address in IP-DHCP-LEASE from another script

Tue Jun 10, 2025 2:15 am

Friends, I want to delete the mac address in IP DHCP leases by searching for that mac address in IP Hotspot Cookies.
I have this script, but it doesn't delete it.

:local Maddress [/ip hotspot cookie get [find where user="test"] mac-address]
/ip dhcp-server lease remove $Maddress
no such item


Thank you for your valuable help.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 13145
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Remove mac address in IP-DHCP-LEASE from another script

Tue Jun 10, 2025 11:32 am

remove where?
 
FRANKMUNOZAPURE
newbie
Topic Author
Posts: 28
Joined: Thu May 23, 2024 11:57 am

Re: Remove mac address in IP-DHCP-LEASE from another script

Tue Jun 10, 2025 3:32 pm

Remove from /ip dhcp server lease.


Thank you.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 13145
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Remove mac address in IP-DHCP-LEASE from another script

Tue Jun 10, 2025 4:55 pm

So, remove what? remove want a number (from print) or an item id... and MAC address is not one and not another.
why don't you put the [find where ...], that return the apporpriate id wanted from remove, in the script like on first line?
 
FRANKMUNOZAPURE
newbie
Topic Author
Posts: 28
Joined: Thu May 23, 2024 11:57 am

Re: Remove mac address in IP-DHCP-LEASE from another script

Tue Jun 10, 2025 5:24 pm

I've tried as you say.
:local Maddress [/ip hotspot cookie get [find where user="test"] mac-address]
/ip dhcp-server lease remove [find where=$Maddress]


I don't understand anything.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 13145
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Remove mac address in IP-DHCP-LEASE from another script

Tue Jun 10, 2025 6:09 pm

why on first you do not wrote [find where="test"] ???
the reason why it doesn't work in the second line is the same.

you're close... compare the two [find ...] and see why the second one is not similar to the first one.
 
FRANKMUNOZAPURE
newbie
Topic Author
Posts: 28
Joined: Thu May 23, 2024 11:57 am

Re: Remove mac address in IP-DHCP-LEASE from another script

Tue Jun 10, 2025 9:05 pm

{
{... :local Maddress [/ip hotspot cookie get [find where user="test"] mac-address]
{... :put $Maddress
{... /ip dhcp-server lease remove $Maddress
{... }
EE:03:76:97:AF:8A
no such item
 
FRANKMUNOZAPURE
newbie
Topic Author
Posts: 28
Joined: Thu May 23, 2024 11:57 am

Re: Remove mac address in IP-DHCP-LEASE from another script

Wed Jun 11, 2025 3:28 pm

Can you help me sir REXTENDED.
 
jaclaz
Forum Guru
Forum Guru
Posts: 3104
Joined: Tue Oct 03, 2023 4:21 pm

Re: Remove mac address in IP-DHCP-LEASE from another script  [SOLVED]

Wed Jun 11, 2025 3:52 pm

Let's see if I can help.
This is not strictly Mikrotik specific, in *most* scripting language something like this:
[/ip hotspot cookie get [find where user="test"] mac-address]
loosely means:
in the context of current place (/ip hotspot cookie) get the value of the field mac-address of the entry where the value of field user is equal to "test"

Now, the:
/ip dhcp-server lease remove [find where=$Maddress]
can be written as:
in the context of current place (/ip dhcp-server lease) remove the entry(ies) where the value of the field "MISSING?" :shock: is equal to the value of the variable $Maddress