Hello! I need to update access list and i decided to do it via script. I found it here https://wiki.mikrotik.com/wiki/Using_Fetch_and_Scripting_to_add_IP_Address_Lists. After main script, i entered my 3 lines of code:
:log info "Update!!";
/file remove [find where name=kg-nets.txt];
:log info "File deleted";
When i script, it update address-list, but the last 3 lines of code, which i entered, does not execute.
So, why it does not execute lines:
:log info "Update!!";
/file remove [find where name=kg-nets.txt];
:log info "File deleted";
This is full script:
{
/tool fetch url="http://ip.elcat.kg/kg-nets.txt" mode=ftp
:if ( [/file get [/file find name=kg-nets.txt] size] > 0 ) do={
/ip firewall address-list remove [/ip firewall address-list find list=KG-ZONE];
:global content [/file get [/file find name=kg-nets.txt] contents] ;
:global contentLen [ :len $content ] ;
:global lineEnd nil;
:global line "";
:global lastEnd nil;
:do {
:set lineEnd [:find $content "\n" $lastEnd ] ;
:set line [:pick $content $lastEnd $lineEnd] ;
:set lastEnd ( $lineEnd + 1 ) ;
:local entry [:pick $line 0 ($lineEnd -1) ]
:if ( [:len $entry ] > 0 ) do={
/ip firewall address-list add list=KG-ZONE address=$entry;
}
} while ($lineEnd < $contentLen);
}
:log info "Update!!";
/file remove [find where name=kg-nets.txt];
:log info "File deleted";
}
Help me, please