I have put together the below script and tried other variants but I can only get 1 of the variables to pull at a time and export. doesnt matter if its address, mac-address, server etc. The min I add more variables it creates a file that shows the current file structure and not the output.
If I try multiple :local address :local mac etc it will not even create a file.
Open for my noob ideas to be fixed. 2 versions below I have played with.
Code: Select all
:local output ""
:local filename "dhcp-leases.txt"
:local entry
/ip dhcp-server lease
:foreach i in=[find where server=fttx-public-dhcp] do={
:set entry ([get $i address].",".[get $i mac-address].",".[get $i client-id].",".[get $i server])
:set output ($output . "$entry\r\n")
}
/file print file=$filename
:delay 2s
/file set $filename contents=$output
Code: Select all
:local filename "dhcp-leases.txt"
/file set $filename contents=""
/ip dhcp-server lease
:foreach i in=[find where server=fttx-public-dhcp] do={
:local address [get $i address]
:local mac [get $i mac-address]
:local client_id [get $i client-id]
:local server [get $i server]
:local entry "$address,$mac,$client_id,$server"
:put ("$entry")
/file print file=$filename