Community discussions

MikroTik App
 
Aroca
just joined
Topic Author
Posts: 16
Joined: Mon Jun 02, 2008 6:13 pm
Location: Spain

Run a script via API

Wed Jul 30, 2008 2:36 pm

I have a java API GUI. It works fine with all the commands I've tried, but when i try to run a script it doesn't run.
I send to ros "/system/script/run"+"\n"+"=.id=name of the script".
I'm using janisk java API as a start point.
Does anyone know why it's not working??
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7042
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Run a script via API

Wed Jul 30, 2008 2:49 pm

=.id=script name wont work.

Use /system/script/print to find scripts ID, for example scripts id=*1e
and then use
/system/script/run =.id=*1e
 
Aroca
just joined
Topic Author
Posts: 16
Joined: Mon Jun 02, 2008 6:13 pm
Location: Spain

Re: Run a script via API

Thu Jul 31, 2008 1:52 pm

I can't use /system/script/print in API, it doesn't respond. I've acquired id in winbox and displayed it in my API, but it doesn't run properly. It runs the script, as run count increments, but not execute the script code (I think).
If I launch the script in winbox or via ssh it works fine.
Any clue??
I'm using v3.11.

Regards, Agustin
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7042
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Run a script via API

Thu Jul 31, 2008 2:21 pm

I was able to /system/script/print in api and run any script from the list without problems.

Post your script here.
 
Aroca
just joined
Topic Author
Posts: 16
Joined: Mon Jun 02, 2008 6:13 pm
Location: Spain

Re: Run a script via API

Fri Aug 01, 2008 10:54 am

Here is the script I'm trying to run:

:global trabajo
:set trabajo [/system script job find script=connect_3G]
:if ($trabajo !=" ") do={
/system script job remove $trabajo
}
:set trabajo [/system script job find script=disconnect_3G]
:if ($trabajo !=" ") do={
/system script job remove $trabajo
}

When I use /system/script/print, it doesn't respond. If tried it in winbox and it shows me the source of the first script and then appears Q-Quit, D-Dump.

Any clue??
What's bothering me is the fact that the run count is increasing when I execute in my API GUI /system/script/run
=.id=id obteined in winbox.
I've tried to do it via winbox or ssh, and the script works fine.

Any clue??
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7042
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Run a script via API

Fri Aug 01, 2008 11:26 am

It looks like script executed from API is unable to see entries in /system script job. You should contact mikrotik support.
 
Aroca
just joined
Topic Author
Posts: 16
Joined: Mon Jun 02, 2008 6:13 pm
Location: Spain

Re: Run a script via API

Fri Aug 01, 2008 11:33 am

I'm going to contact with support.
Thanks for your help, anyways.
 
snn1024a
just joined
Posts: 2
Joined: Mon Dec 08, 2014 6:58 pm

Re: Run a script via API

Fri Jan 16, 2015 8:23 pm

$API->comm("/system/script/run", array('number'=>'0'));

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot], apitsos, maxslug, smirgo and 68 guests