Setup guide
system script
Description
In RouterOS, a script may be started in three different ways:
• according to a specific time or an interval of time
• on an event - for example, if the netwatch tool sees that an address does not respond to pings
• by another script
Property Description
source (text; default: "") - the script source code itself
owner (name; default: admin) - the name of the user who created the script
run-count (integer; default: 0) - script usage counter. This counter is incremented each time the
script is executed. The counter will reset after reboot.
last-started (time) - date and time when the script has been last invoked. The argument is shown
only if the run-count!=0.
policy (multiple choice: ftp | local | policy | read | reboot | ssh | telnet | test | web | write; default:
reboot,read,write,policy,test) - the list of the policies applicable:
• ftp - user can log on remotely via ftp and send and retrieve files from the router
• local - user can log on locally via console
• policy - manage user policies, add and remove user
• read - user can retrieve the configuration
• reboot - user can reboot the router
• ssh - user can log on remotely via secure shell
• telnet - user can log on remotely via telnet
• test - user can run ping, traceroute, bandwidth test
• web - user can log on remotely via http
• write - user can retrieve and change the configuration
Command Description
run (name) - executes a given script
Notes
You cannot do more in scripts than you are allowed to do by your current user rights, that is, you
cannot use disabled policies. For example, if there is a policy group in /user group which allows
you ssh,local,telnet,read,write,policy,test,web and this group is assigned to your user name, then
you cannot make a script that reboots the router.
Example
The following example is a script for writing message "Hello World!" to the system log:
[admin@Wandy] system script> add name=log-test source={:log \
\... message="Hello World!"}
[admin@Wandy] system script> print
0 name="log-test" source=":log message="Hello World!"" owner="admin"
policy=reboot,read,write,policy,test last-started=dec/06/1999 20:07:37
run-count=1
[admin@Wandy] system script>