where can I create a script in RouterOS?

Hello to all,

I am very new at scripting, I’ve been reading scripting examples and scripting manuals at the wiki
http://wiki.mikrotik.com/wiki/Manual:Scripting

and I can understand those pretty well…but i have no idea where to create the scirpt, and is that I open a new terminal and start

[admin@MKTStation] >:global currentIP;
[admin@MKTStation] >:local newIP [/ip address get [find interface="ether1"] address];
[admin@MKTStation] >:if ($newIP != $currentIP) do={
syntax error (line 1 column 7)

Can you understand what i mean?? :question: :question: …is that I don´t know where to put the script…hopefully I am explaining myself right, can I put it in a notepad and then upload it into files or what? and if it does..what is the extension? .rsc? .txt?

Thanks a lot for your help and support

Regards

/system script

You can add a script there:

/system script add name=test

And use the built in editor to edit the source:

/system script edit [/system script find name=test] source

Thanks a lot fewi…you always help me really quick!!

Is it also possible to create and view scripts in the web gui?

Yes, same like in Winbox, you have two possibilities - to click the [Terminal] button to get a command line window, or to go System → Scripts and edit just the script body itself in the form. But if the script has to output something, run it from the command line window.

After adding your script, you want to do it automatically. :wink:

please refer:
/system scheduler
(= GNU/Linux cronjobs)

Could I also create a script from within an .rsc file ? Or can I ftp the script contents as a file and turn them into a script from command line ?

I would like to version control my config and script outside of RouterOS, that’s why I’m asking.

Lars

Sure, everything is possible… Run

/ system script export;

to see what the code inside an rsc file should look.

To turn an uploaded file into a script:

/ system script add name=new-script source=[ /file get uploaded-script-file contents ];

You may want to take a look at my signature for an idea what’s possible. :smiley:

Great, Danke !

Lars

You can create a script in a house,
You can create a script with a mouse
You can create a script with the help of fewi
You can create a script with the webgui
You can create a script with green eggs and ham!!

I don’t like the looks of green eggs and if, then I would hide it under the ham.

I do see many struggle to get script to work on the terminal.

Example if you cut and past this to terminal, you do not get anything out. But will work fine as a saved script.

:local test "My script"
:put $test

To get it to work in the terminal wrap it in brackets {}

{
:local test "My script"
:put $test
}

This will then output “My script”