Community discussions

 
alger
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 64
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 ?
Alexander
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2342
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
PEAR2_Net_RouterOS(1.0.0b6) - My API client in PHP
(Rate my posts? If you want... no pressure...)
 
alger
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 64
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.
Alexander
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2342
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.
PEAR2_Net_RouterOS(1.0.0b6) - My API client in PHP
(Rate my posts? If you want... no pressure...)

Who is online

Users browsing this forum: No registered users and 8 guests