System information

Manual:Scripting-examples
45
:put "Sending e-mail.";
/tool e-mail send \
to=$SYSsendemail \
subject=($SYSname . " NTP change") \
from=$SYSmyemail \
server=$SYSemailserver \
body=("Your NTP servers have just been changed:\n\nPrimary:\nOld: " . $ntpcura . "\nNew: " \
. $ntpipa . "\n\nSecondary\nOld: " . $ntpcurb . "\nNew: " . $ntpipb);
}
Scheduler entry:
/system scheduler add \
comment="Check and set NTP servers" \
disabled=no \
interval=12h \
name=CheckNTPServers \
on-event=setntppool \
policy=read,write,test \
start-date=jan/01/1970 \
start-time=16:00:00
Auto upgrade script
Auto_upgrade_script_V3.x
Other scripts known to work with latest v3.x
Dynamic_DNS_Update_Script_for_EveryDNS
Dynamic_DNS_Update_Script_for_ChangeIP.com
UPS Script
LUA Scripting examples
NOTE!
After RouterOS v4.0beta4, Lua support is removed until further notice
In v4.0beta3 Lua scripting language is integrated in console. This integration allows users to create their own
functions and bypass several command line scripting limitations.
All examples below require at least basic knowledge of Lua scripting language. Good tutorials can be found here
[1]
as a starting point.
Print function
As stated in Lua documentation, 'print' command is not available in RouterOS compared to standard Lua release.
This example will show you how to get back 'print' command
-- ------------------------------------------------------------------------
-- Print function
-- ------------------------------------------------------------------------
function print (...)
local strPrintResult = ""