Within a file ipaddress.txt there is a list of IPs, each on a line. The idea is to run the script and have it add them to a blocking address list. When I run the script I get the following error "is not a valid dns name".
ipaddress.txt example:
192.168.23.1
195.53.123.19
207.143.214.26
Script:
:if ( [/file get [/file find name=ipaddress.txt] size] > 0 ) do={
# Remove exisiting addresses from the current Address list
/ip firewall address-list remove [/ip firewall address-list find list=MY-IP-LIST]}
:global content [/file get [/file find name=ipaddress.txt] contents] ;
:global contentLen [ :len $content ] ;
:global lineEnd 0;
:global line "";
:global lastEnd 0;
:while ($lineEnd < $contentLen) do={
:set lineEnd [:find $content "\n" $lastEnd ] ;
:set line [:pick $content $lastEnd $lineEnd] ;
:set lastEnd ( $lineEnd + 1 ) ;
:local entry [:pick $line 0 $lineEnd ]
:if ( [:len $entry ] > 0 ) do={
/ip firewall address-list add list="MY-IP-LIST" address=$entry
}
}
I can't find the problem, if anyone can help me with this I appreciate it
Thank you!