There is a comma separated values in file MAC,ADDRESS,SERVER,COMMENT
Code: Select all
00:00:00:00:00:00,XXX.XXX.XXX.XXX,DEFCONF,HOSTNAME1
00:00:00:00:00:00,XXX.XXX.XXX.XXX,DEFCONF,HOSTNAME2
00:00:00:00:00:00,XXX.XXX.XXX.XXX,DEFCONF,HOSTNAME3
00:00:00:00:00:00,XXX.XXX.XXX.XXX,DEFCONF,HOSTNAME4
Comma separated values is considered a values in an array, so the string I get I split into an array.
Once it's split it should get each value corresponding with its index and add the record to the mac table.
Code: Select all
:local filename "mac_table.txt";
:local content [/file get [/file find name=$filename] contents];
:foreach line in=[:find $content "\n" ] do={
:local array [:toarray $line];
:local mac-address = array[1]
:local address = array[2]
:local server = array[3]
:local comment = array[4]
:if ([/ip dhcp-server lease find=$mac-address] = false) do {
/ip dhcp-server lease add mac-address=$mac-address address=$address server=$server comment=$comment
}
}
Actually, the script doesn't work. The problem I'm facing I cannot understand how to debug it?