H
H
HawK2017-02-10 04:25:13
Mikrotik
HawK, 2017-02-10 04:25:13

What are the differences in the script syntax in the 5th and 6th versions of Router OS?

There is a wonderful service for generating scripts for blocking ads on the MikroTik gateway. Creates the following script, which works fine in 6 versions of ROS:

:local hostScriptUrl "http://stopad.generate.club/?sources=https%3A%2F%2Fcdn.rawgit.com%2Ftarampampam%2Fstatic%2Fmaster%2Fhosts%2Fblock_shit.txt,http%3A%2F%2Fadaway.org%2Fhosts.txt,http%3A%2F%2Fgoo.gl%2FcJHHzf&format=routeros&version=0.1.0&exceptions=localhost";

:local scriptName "stop_ad.script";
:local backupFileName "before_stopad";
:local logPrefix "[StopAD]";

do {
 /tool fetch mode=http url=$hostScriptUrl dst-path=("./".$scriptName);
 :if ([:len [/file find name=$scriptName]] > 0) do={
   /system backup save name=$backupFileName;
   :delay 1s;
   :if ([:len [/file find name=($backupFileName.".backup")]] > 0) do={
     /ip dns static remove [/ip dns static find comment=ADBlock];
     /import file-name=$scriptName;
     /file remove $scriptName;
     :log info "$logPrefix AD block script imported, backup file (\"$backupFileName.backup\") created";
   } else={
     :log warning "$logPrefix Backup file not created, importing AD block script stopped";
   }
 } else={
   :log warning "$logPrefix Backup file not downloaded, script stopped";
 }
} on-error={
 :log warning "$logPrefix AD block script download FAILED";
};

How can this script be adapted to work in ROS 5.26?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri Bortnik, 2017-03-08
@DrakeMazzy

This script adapts without problems, but the one that is downloaded - how are you going to process it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question