I am trying to make this script to get a list of addresses coming from dhcp-server lease. And that I register it in a text file.
Code: Select all
{
:local output ""
:local filename "mac_address.txt";
/ip dhcp-server lease
:foreach i in=[find] do={
:local hname [get $i host-name]
if ($hname = "") do={
:set output ($output . ([get $i address]."\t".[get $i mac-address]."\t".[get $i comment ]) . "\n");
} else {
:set output ($output . ([get $i address]."\t".[get $i mac-address]."\t".[get $i host-name ]) . "\n");
}
}
/file print file=$filename;
:delay 1;
/file set $filename contents=$output;
}
- address
- mac-address
- If there is host-name, show me that value and if not, show me the value of the comment.
I have some problem with the code as it doesn't work well for me. Can you help me?
BR.