Page 1 of 1

execute command from API

Posted: Fri Dec 09, 2022 6:55 am
by BrianHiggins
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.

Re: execute command from API

Posted: Mon Feb 12, 2024 4:32 am
by israelrmm
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