I have a list of banned IP's that I update all the time for customers who are overdue on their payments. I'm following the instructions on this page http://wiki.mikrotik.com/wiki/Using_Fet ... ress_Lists but having no luck. The fetch script works just fine, my suspendedaccts.txt file shows up in the Mikrotik's files folder and it runs the next script. That next script, however, does not parse my list of IP's and add them in the address-list. What's wrong here?
Code: Select all
:if ( [/file get [/file find name=suspendedaccts.txt] size] > 0 ) do={
# Remove exisiting addresses from the current Address list
/ip firewall address-list remove [/ip firewall address-list find list=suspendedaccts]
:global content [/file get [/file find name=suspendedaccts.txt] contents] ;
:global contentLen [ :len $content ] ;
:global lineEnd 0;
:global line "";
:global lastEnd 0;
:do {
:set lineEnd [:find $content "\n" $lastEnd ] ;
:set line [:pick $content $lastEnd $lineEnd] ;
:set lastEnd ( $lineEnd + 1 ) ;
#If the line doesn't start with a hash then process and add to the list
:if ( [:pick $line 0 1] != "#" ) do={
:local entry [:pick $line 0 ($lineEnd -1) ]
:if ( [:len $entry ] > 0 ) do={
/ip firewall address-list add list=suspendedaccts address=$entry
}
}
} while ($lineEnd < $contentLen)
}