How do I use a MicroTik API to do a /tool fetch command?

Viewed 298

Having an issue trying to use a MicroTik API to issue a /tool fetch command and download a file to a router. I am using a ccr1016 on 6.47.9.

My php script calls this API:

require('lib/routeros.class.php');

The code I am using currently is this:

 $fileUrl = "http://".$localIP."/".$remoteSysModel."/".$fileName;
 $remoteAPI->write('/tool fetch', false);
 $remoteAPI->write('=url='.$fileUrl.'');

Also tried:

$remoteAPI->write('/tool fetch url='.$fileUrl.'');

Both of the above are unsuccessful nothing downloads. Any advice much appreciated.

The API is definitely connecting correctly because i retrieve info from the router using this commend $remoteAPI->comm('/system/routerboard/print'); earlier in the script.

The $fileUrl variable is correct as well and contains this string http://172.27.55.120/rb2011/routeros-verv-6.47.9.npk

Also if i run the command /tool fetch url=http://172.27.55.120/rb2011/routeros-verv-6.47.9.npk in the router cli through winbox, it works correctly and the file downloads.

Any help would be greatly appreciated.

Thanks in advance

0 Answers
Related