Community discussions

MikroTik App
 
alger
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 80
Joined: Tue Dec 19, 2006 12:35 pm
Location: Russia
Contact:

PEAR2\Net\RouterOS export

Wed Sep 13, 2017 2:03 pm

Please tell me how to PEAR2\Net\RouterOS to get the result of command /export ?
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: PEAR2\Net\RouterOS export

Wed Sep 13, 2017 4:43 pm

At least in current versions, /export doesn't return anything over the API, so you can't just output it.

You can use the "file" argument to export to a file, and then read the file though.

e.g.
$exportFileName = 'EXPORT.rsc';

$util = new RouterOS\Util($client = new RouterOS\Client('192.168.88.1', 'admin', 'password'));

$client->sendSync($util->newRequest('export', array('file' => $exportFileName));
sleep(2);//Wait for RouterOS to write the file to disk
$export = $util->fileGetContents($exportFileName);
$util->filePutContents($exportFileName, null);//Optional; Remove the file from the router
 
alger
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 80
Joined: Tue Dec 19, 2006 12:35 pm
Location: Russia
Contact:

Re: PEAR2\Net\RouterOS export

Wed Sep 13, 2017 4:51 pm

Possible without a file? like "export " from telnet
Don't want to write on the hdd.
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: PEAR2\Net\RouterOS export

Wed Sep 13, 2017 5:03 pm

Sadly, no. Not with current versions at least.

You can remove the file, as in the example above, but you do have to make the HDD write.

Who is online

Users browsing this forum: No registered users and 7 guests