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
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?
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”
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?” is equal to the value of the variable $Maddress