I have a script that download a text file from remote website. Then it will go through the file line by line to all entry into walled-garden ip list. However, the relevant dynamic entries are not added into walled-garden and firewall filters.
I follow example as depicted in this http://wiki.mikrotik.com/wiki/Manual:IP/Hotspot/Walled_Garden
When I run the command to add it will add relevant entries into firewall to open connection. However, when I run through script, it will just add the entry in walled-garden IP.
Here is the script that does not work:
/tool fetch url="http://mydomain.com/walldownload.php?ap=$[/system identity get name]" mode=http dst-path=wall.txt
:foreach entry in=[/ip hotspot walled-garden ip find comment=walltemp] do={
/ip hotspot walled-garden ip remove $entry
}
:if ( [/file get [/file find name=wall.txt] size] > 0 ) do={
:global content [/file get [/file find name=wall.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 ( [:pick $line 0 1] != "#" ) do={
:local entry [:pick $line 0 ($lineEnd -1) ]
:if ( [:len $entry ] > 0 ) do={
/ip hotspot walled-garden ip add action=accept disabled=no dst-host="$entry" comment=walltemp server=hotspot1;
}
}
} while ($lineEnd < $contentLen)
}
Here is a test script I run from script that works:
/ip hotspot walled-garden ip add action=accept disabled=no dst-host="yahoo.com" comment=walltemp server=hotspot1;
Anyone can help with this problem?