AGI doesn't work

Hello everyone! :smiley:

I have a problem with agi - php scripts:

versions:
php 5.2.3
asterisk 1.4.10
ubuntu 7.10 (kernel 2.6.22-14)

Problem description:
If i execute php script stand alone, it works well

$ php test-agi.php Connessione riuscita! SET VARIABLE NAME "pippo" ...other agi setting & outputs

But if i call the same script from asterisk cli, i receive the output:

But i have no AGI output about setting variables, like the stand alone execution has…

In my extension.conf i have

... exten => s,7,agi(test-agi.php,${NAME}) ...

the php script:

[code]#!/usr/bin/php -q

<?php require "phpagi.php"; require "database.php"; ob_implicit_flush(true); $stdlog = fopen('/var/log/asterisk/agiphp.log', 'w'); $agi = new AGI(); $set_name = $agi->set_variable("NAME", "pippo"); $name = $agi->get_variable($set_name); $query = "insert into table (pin, sorgente, uniqueid) values ('1111', '1111', '1111');"; $result = pg_exec($conn, $query); $query = "select * from table where uniqueid like '1111' order by data_inizio desc;"; $result = pg_exec($conn, $query); $r = pg_fetch_object($result, 0); $id = $r->id; $set_name = $agi->set_variable("NAME", $id); $name = $agi->get_variable($set_name); ?>

[/code]
thank you in advance :smile:

use verbose to debug this script

with VERBOSE i don’t see nothing in the asterisk cli…neither with php function echo nor with stdout…or others…

I only see output if i call the php page like i specified before:

$ php page.php
VERBOSE bla bla
…OUTPUT…

this is the problem i don’t see any agi output…

I checked my agi scripts and I see they all are executables, does yours are ?

Cheers.

Marco Bruni

Yes they are all executable…
i gave them ‘chmod a+x *.php’

As you can see, the * cli output said
– AGI Script test-agi.php completed, returning 0

so * can run the the script…but with no agi output, and with the bad execution of the script.

I also installed the php5-cli and php5-cgi packages, and it seems that with the cgi in the *cli i receive “510 Invalid Command” so i use php-cli-version…

Could the problem be ubuntu or php5 ?

I use php5 with agi and * without problems so this shouldn’t be the problem, I don’t know about ubuntu because I use opensuse but I don’t think it’s the cause of the problem; if you start the agi debug what you see in the * cli ?

Cheers.

Marco Bruni

I see the agi variables with their values…only this

agi_request = value
agi_channel = value
etc…

I did a quick search, this problem is reported many times, there is an errror in the php script for sure, this happened to me too in the past; try comment out blocks of code one at a time and just print a debug statement to see where the error is.

Cheers and good luck.

Marco Bruni

I don’t think so…
If i play the php-script alone it works well without errors.
Plus i tried other scripts (eg. voip-info.org/wiki/view/Asterisk+AGI+php)… with all the same result in the cli …

try renaming your script as .agi instead of .php

regards

[quote=“vaio73”]try renaming your script as .agi instead of .php

regards[/quote]

I already tried it… but it’s the same result :angry:

Now i’m trying another distro… :unamused: