Running a script from API

Hi,

I’m having problems with running a script from Python API. Lets say the script is called “temp”. Through Winbox terminal I’m running the script using following command: /system script run temp

According to manual, in API one should call the same script using:
/system/script/run
=name=temp

However, this call doesn’t work, I’m getting trap message “script not found”.

I’ve managed to call the script using:
/system/script/run
=.id=*6

However, this call is not practical - if you add additional scripts, ID changes and you have to update your API code…

Is it possible to call the script by the name parameter?

Thanks
Zreno

First use the API to find the ID of the script with the specific name you are looking for, then run the script with that ID number.

first, use latest RouterOS availabe or name on what version you are trying to run something.

second,

/system/script/run
=.id=script1

is running for me without problems. but do not consider that you will get any meaningful output into API, as API does not support any scripting constructs etc. Best shoot is to set up global variable that afterwards can be read from using API.

I’m using API PHP Class from wiki and with routerOS 4.11 still have the problem “script not found”.

I add try:

routeros->write("/system/script/run",1);
routeros->write("=.id=script_name",1);

and also:

routeros->write("/system/script/getall",1);
routeros->write("/system/script/run",1);
routeros->write("=.id=*3",1);

where *3 is the id of script_name

What’s wrong ?

check what arguments you have to set when you send command to routeros through API using php implementation.

when you have to set false and when true (or 1 or 0) at what point.