[asterisk-users] [AGI 1.4] Why doesn't Asterisk complain?

Vincent vincent.delporte at bigfoot.com
Mon Jan 28 01:08:49 CST 2008


Hello

	I've read in the documentation that we should use the CLI
version of PHP when using it to write scripts called by AGI, because
the prepended HTML bits would confuse Asterisk when it got a reply
from the script through STDIN.

And still, the following works OK, although the CLI version available
in AstLinux prepends some HTML:

===================
pbx tmp # cat /tmp/test.php 
#/tmp/php-cli -q
<?php
echo "SET CALLERID \"Derf <123>\"\n";
?>

pbx tmp # ./test.php 
X-Powered-By: PHP/5.2.5
Content-type: text/html

pbx tmp # /tmp/php-cli -q test.php 
SET CALLERID "Derf <123>"
======== /etc/asterisk/extensions.conf ====
[inside]
exten => 9999,1,Verbose(Name=${CALLERID(name)}
number=${CALLERID(num)}) 
exten => 9999,n,AGI(/tmp/test.php)
exten => 9999,n,Verbose(Name=${CALLERID(name)}
number=${CALLERID(num)}) 
======== Calling in ====
pbx*CLI> 
    -- Executing [9999 at inside:1] Verbose("SIP/2000-081da3a0",
"Name=Fred number=2000") in new stack
Name=Fred number=2000
    -- Executing [9999 at inside:2] AGI("SIP/2000-081da3a0",
"/tmp/test.php") in new stack
    -- Launched AGI Script /tmp/test.php
    -- AGI Script /tmp/test.php completed, returning 0
    -- Executing [9999 at inside:3] Verbose("SIP/2000-081da3a0",
"Name=Derf number=456") in new stack
Name=Derf number=456
  == Auto fallthrough, channel 'SIP/2000-081da3a0' status is 'UNKNOWN'
pbx*CLI> 
===================

=> How come Asterisk accepts the reply from the PHP script, even
though it's a mix of HTML and a valid AGI command ("SET CALLERID")?

Thank you.




More information about the asterisk-users mailing list