Community discussions

MikroTik App
 
User avatar
BrianHiggins
Forum Veteran
Forum Veteran
Topic Author
Posts: 702
Joined: Mon Jan 16, 2006 6:07 am
Location: Norwalk, CT
Contact:

execute command from API

Fri Dec 09, 2022 6:55 am

I'm trying to use the API to launch a command, specifically one launched using execute so that it runs async and the API returns success/finished/!done etc while the long running command stays running. I've tried every variation of API syntax I can think of, and while the sample below runs, it doesn't actually remove the sample file
sample example command:
/execute
=script="/file remove samplefile.txt"
The actual command line command I want to launch from the API is:
/execute [/system sup-out file=api_supout.rif]
If I run the sup-out command as a regular API request it times out on the API call side, though the supout does eventually create, albeit using the default filename not the one specified. I need to run it from the API like it runs from the command line and immediately return, avoid the API timeout.
 
israelrmm
just joined
Posts: 1
Joined: Wed Oct 04, 2023 3:21 pm

Re: execute command from API

Mon Feb 12, 2024 4:32 am

Download an replace your routeros api with this:
https://github.com/israelrmm/routeros-a ... .class.php

then add this code in your php file

$API->execmd("/file remove samplefile.txt");

enjoy

Who is online

Users browsing this forum: No registered users and 15 guests