Hi, I have this script that exports the IP addresses of this list to a file.
But I have a problem and if I run the script again it adds ALL the IPs again, I would like please to indicate me an "IF" condition to compare the "address-list" with the content of the file and only add the new IPs that are not in the file.
Is this possible? Thank you.
Code:
/ip firewall address-list:foreach id in=[find list=servers] do={ :local ipAddr [:toip [get $id address]] :local filenameIP "servers100.txt" /file :if ([:len [find where name="flash" and type="disk"]] = 1) do={:set filenameIP "flash/$filenameIP"} :if ([:len [find where name=$filenameIP]] = 0) do={print file="$filenameIP"; :delay 2s; set $filenameIP contents=""} :local filecontent [get $filenameIP contents] :local newfilecontent "$ipAddr\r\n$filecontent" set $filenameIP contents=$newfilecontent; :delay 1s}
But I have a problem and if I run the script again it adds ALL the IPs again, I would like please to indicate me an "IF" condition to compare the "address-list" with the content of the file and only add the new IPs that are not in the file.
Is this possible? Thank you.
Statistics: Posted by diamuxin — Fri Jan 26, 2024 6:24 pm