Community discussions

MikroTik App
 
gregclemmons
just joined
Topic Author
Posts: 19
Joined: Mon May 19, 2008 4:53 am

limit export to one or two address-list?

Tue Dec 16, 2014 4:19 am

/ip firewall address-list export file=AddList.rsc

How do I use the above in a script to export only the two desired list "DHCP" and "CutOff"?

Help appreciated new to scripting. very powerful tool..

Greg
 
User avatar
skot
Long time Member
Long time Member
Posts: 584
Joined: Wed Nov 30, 2011 3:05 am

Re: limit export to one or two address-list?

Thu Dec 18, 2014 9:26 pm

You can't export it directly... but you could run a script that extracts those lists and prints them to the console. Then you could copy/paste the text and save it to a text document.
{
/ip firewall address-list

:local myList {"DHCP";"CutOff"}

:local output "/ip firewall address-list\r\n"

:foreach i in=[find] do={
  :local name [get $i list]
  :foreach j in=$myList do={
    :if ($name = "$j") do={
      :set output ($output . "add address=$[get $i address] list=$name\r\n")
	}
  }
}

:put $output
}
 
User avatar
inteq
Member
Member
Posts: 430
Joined: Wed Feb 25, 2015 8:15 pm
Location: Romania

Re: limit export to one or two address-list?

Mon Sep 28, 2015 7:18 pm

Any news on this?
I too would like to be able to export only a particular address-list for automation.(without copy paste)
I managed to convert all dynamic records to static on a schedule so this is not a problem.
Still no luck?
 
User avatar
inteq
Member
Member
Posts: 430
Joined: Wed Feb 25, 2015 8:15 pm
Location: Romania

Re: limit export to one or two address-list?

Tue Sep 29, 2015 1:56 am

Found the solution! http://forum.mikrotik.com/viewtopic.php?t=16411#p160122
/ip firewall address-list print file=SomeFileName where list="SomeAddressListName"