I`ll read more about API syntax but seems that using SSH for PHP would be better solution since I can pass variables and use regular CLI syntax as I use in Terminal window…
well, still nothing … anyway now I`m keen to try solution were I can be more comfortable - execute regular CLI command, get output and parse it in web page.
I have installed php ssh2 (a bit tricky indeed) and works fine when I wanna connect to some other server and execute some shell command.
Here is what mikrotik says when I try to establish ssh connection with my test router:
Warning: ssh2_connect() [function.ssh2-connect]: Error starting up SSH connection(-5): Unable to exchange encryption keys in /home/xxx/public_html/xxx/test/ssh2.php on line 4
Warning: ssh2_connect() [function.ssh2-connect]: Unable to connect to 10.11.126.250 in /home/xxx/public_html/xxx/test/ssh2.php on line 4
fail: unable to establish connection
Any help about establishing ssh connection with mikrotik?
all commands which I wanted to execute - manage users, playing around with firewall rules - have completed without any issues, syntax is exactly same as I wanted to do in CLI (what was the idea), but now I have the problem to get the OUTPUT?
I read many forums and there are lot of reports about it. However I`m able to get the output from some other Linux (testing “ls -al”) but without success with mikrotik?
here is the code:
// collect returning data from command original
stream_set_blocking( $stream, true );
$data = "";
while( $buf = fread($stream,4096) ){
$data .= $buf;
}
fclose($stream);
I have tried also withoud while loop, but no still no success. I`m just waiting to resolve this and then I can fully integrate various scripts with our billing database …
Just one note, I`m able to get data from the test router using API, but I preferred to stay on this method since it would be really easy to integrate in existing system.
Sorry. I know I am Brazilian and my English is not very good. But what is ninet says (i think) that the code did not work as I mentioned in another post. Soon we may conclude that the solution is not here.
ninet Response:
Thank you mrz for your reply,
I got the point, however with your > code I didn`t got new user > on my test router, browser output is:
The solution they found was with SSH2. Why you asked them to change the discussion to another site more appropriate since we’re talking about the PHP API.