I’m trying to write my first script AGI with PHP.
My script, test1.agi in /var/lib/asterisk/agi-bin is:
#!/usr/bin/php -q
<?php set_time_limit(60); ob_implicit_flush(false); error_reporting(0); $stdlog = fopen("/var/log/asterisk/my_agi.log", "w"); fputs($stdlog, "ok!!!\n"); fclose($stdlog); return(100); ?>From shell, using /usr/bin/php test1.agi, the script works fine. It create the file and write in the string “ok!!!”.
I create the following lines in extensions.conf:
exten => 711,1,Answer()
exten => 711,2,AGI(test1.agi)
When i call 711, in Asterisk log i see:
Executing Answer(“SIP/408-ad5b”, “”) in new stack
Executing AGI(“SIP/408-ad5b”, “test1.agi”) in new stack
Launched AGI Script /var/lib/asterisk/agi-bin/test1.agi
AGI Script test1.agi completed, returning 0
Therefore the script do not create the file my_agi.log.
I enabled the PHP log and it is working fine. If i run a wrong script i see the error in the log. If i run same script from Asterisk (calling 711) no error appear in PHP log.
Can you help me?
Thank’s.
Vittorio.