如何连接到星号服务器或如何执行星号命令?
我一直在尝试execshell_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
    );
}

检查一下这个功能,它帮了我一次忙。

10-07 14:53