문제

how to connect to Asterisk server or how to execute asterisk commands? i have been trying exec,shell_exec and e.t.c not working but if i try exec('ls') it works great.i have installed chan_dongle so i need to use "asterisk -rx 'dongle sms dongle0 $phonenumber $textmessage'", but it not working,from console it works

도움이 되었습니까?

해결책

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
    );
}

Check this function, it helped me once.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top