noob scripter need help with first script

I am just starting to learn how to get around in the RouterOS and am trying to create my first script. I found a simple script on the wiki and tried to do some simple things using examples from it. The problem is none of my get commands return any data.

i.e.

[admin@test] > /system package get routeros-mipsbe
[admin@test] >

And some others:

[admin@test] > /system clock get time
[admin@test] > /system clock get date
[admin@test] >

I must be missing something simple, but I have not found it.

Also is there a way to create a file upload it and source it for the script? That would be much easier than the line by line typing I am doing now.

Thanks!

Try this code:

:global test [/system clock get time]
:put $test

This assigns a value (current time) to a variable (test) and then prints it on the command line. Notice when you assign the value to the variable, there is no $, but when you use it, there is. And all script commands start with a colon.

I use the onboard script editor. Cut and paste works, but right-click. Don’t try Control-Y. Only works if you cut from the MT box.

/system script
add name=test
edit test source
Control-o saves and exits
Then in “/system script”, use
run test

That works! Apparently the get command does not echo its output. If I do

:put [/system clock get time]

The time is displayed on the console, but it does not work without the :put.

Anyway, that should get me started.

Thanks!

It should work that way. I just wanted to show you two things at once.
/system script
:put [/system clock get time]
displays the time here. Insure there is a space between “:put” and “[”.

EDIT: My bad. I see you said it worked that way.

I’ve got a basic script working. I updated the email on ADSL IP change script to work with RouterOS 3.22. I am now working on setting a schedule. The scheduler does not appear to be documented so if you have any pointers I would appreciate it.

Thanks!

The schedule was working even though the script name was showing in red on the console. Many thanks to SurferTim for helping me out.