How to execute a shell command from php via ssh and return the result?

Good afternoon.
1. ssh user@95.1.1.95
2. password
3. asterisk -rv 'sip show registry'
4. Close ssh

Question: How to get the output of 3 commands in php?
June 10th 19 at 16:29
3 answers
June 10th 19 at 16:31
Solution
1. ssh user@95.1.1.95
To connect with para 4 - use the rsh or remsh to execute a single command on the remote server
rsh user@95.1.1.95 "asterisk -rv 'sip show registry'"

2. password
This is not necessary, configure authorization on ssh keys to make it safer and to enter the password manually was not necessary.

3. asterisk -rv 'sip show registry'
using rsh or remsh

4. Close ssh
using rsh or remsh

Return value
$result=exec("rsh user@95.1.1.95 \"asterisk -rv 'sip show registry'\"");
print "$result"
June 10th 19 at 16:33
well, as an option,

asterisk -rv 'sip show registry' >somefile_123.txt

$output = file_get_contents('somefile_123.txt');

only need to bother with a unique number (123) of each call to heel himself not to come.

clumsy, but "on the knee to stir up the" go.
June 10th 19 at 16:35

Find more questions by tags PHPCommand line