Community discussions

just joined
Topic Author
Posts: 1
Joined: Sat Nov 17, 2018 5:18 pm

Quick way to load an address list into an array?

Tue Aug 20, 2019 12:39 am

Hi Guys,
I have a script that loads and address list into an array for further processing on the array rather than trying to muck with the address list directly.
This is the code:
# for each IP in the unchecked list load it into an array
:set i (0);
:foreach fwlist in=[/ip firewall address-list find where list=Address_list] do={
  :foreach ip in=[/ip firewall address-list get $fwlist value-name=address] do={
  :set ($array->"$i") $ip;
  :put "$ip is loaded into array at index $i"
  #remove ip from address list once loaded
  /ip firewall address-list { remove [find address=$ip list=Address_list]};
  :set i ($i + 1);
But it takes an age to load the addresses into the array. I'm not the greatest coder but there has to be an easier & faster way to load an Address list into an Array?

Any guidance would be appreciated :)

Who is online

Users browsing this forum: No registered users and 5 guests