如何连接到 Asterisk 服务器或如何执行 asterisk 命令?
我一直在尝试 exec
、shell_exec
和 e.t.c 无法正常工作,但如果我尝试 exec('ls')
效果很好。我已经安装了 chan_dongle所以我需要使用 "asterisk -rx 'dongle sms dongle0 $phonenumber $textmessage'"
,但它不工作,从控制台它工作
最佳答案
private function my_exec($cmd, $input = '')
{
$proc = proc_open($cmd, array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes);
fwrite($pipes[0], $input);
fclose($pipes[0]);
$stdout = stream_get_contents($pipes[1]);
fclose($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
fclose($pipes[2]);
$rtn = proc_close($proc);
return array('stdout' => $stdout,
'stderr' => $stderr,
'return' => $rtn
);
}
检查这个函数,它帮了我一次。
关于php - 从 php 连接到 Asterisk,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23171815/