AGI script failed to execute

From the site:
phpagi.sourceforge.net/phpagi1/phpagi.docs.php
I’m trying to run this AGI script

[ul]

file saynumber.agi

<?php $agi->saynumber("1234"); // speaks the number 1234 $agi->saydigits("1234"); // speaks the digits 1, 2, 3 and 4. $agi->saytime(); // speaks the current time. $agi->text2wav("These are some words eh?"); // speaks the phrase "These are some words eh?" using Festival. $agi->play("welcome"); // plays a file on the current channel. /* Plays the prompt "say-something", then records up to 10000 milliseconds of audio to the file "somefile.gsm" */ $agi->recordfile("somefile","gsm",10000,"say-something"); ?>

[/ul]

exten => 3016,1,Answer()
exten => 3016,n,AGI(saynumber.agi)

– Executing [3016@default:1] Answer(“SIP/1200-b6c04f48”, “”) in new stack
– Executing [3016@default:2] AGI(“SIP/1200-b6c04f48”, “saynumber.agi”) in new stack
– Launched AGI Script /var/lib/asterisk/agi-bin/saynumber.agi
== saynumber.agi: Failed to execute ‘/var/lib/asterisk/agi-bin/saynumber.agi’: Exec format error
– AGI Script saynumber.agi completed, returning 0
== Auto fallthrough, channel ‘SIP/1200-b6c04f48’ status is 'UNKNOWN’
asterisk*CLI>

Calling 3016 Failed to execute. :cry:

You need to create the agi object, so just after the line “<?php” add:

require("phpagi.php");
$agi=new AGI();

Also check you have the file phpagi.php in /var/lib/asterisk/agi-bin.

Regards.

Marco Bruni

However…it still doesn’t work.

– Executing [3016@default:1] Answer(“SIP/1200-b6c21538”, “”) in new stack
– Executing [3016@default:2] AGI(“SIP/1200-b6c21538”, “saynumber.agi”) in new stack
– Launched AGI Script /var/lib/asterisk/agi-bin/saynumber.agi
– AGI Script saynumber.agi completed, returning 0
== Auto fallthrough, channel ‘SIP/1200-b6c21538’ status is ‘UNKNOWN’
asterisk*CLI>

and NO sound. :confused:

[quote=“mbruni”]You need to create the agi object, so just after the line “<?php” add:

require("phpagi.php");
$agi=new AGI();

Also check you have the file phpagi.php in /var/lib/asterisk/agi-bin.

Regards.

Marco Bruni[/quote]
Now the file is like this:
[ul]
#!/opt/lampp/bin/php
<?php
require(“phpagi.php”);
$agi=new AGI();
$agi->saynumber(“1234”); // speaks the number 1234
$agi->saydigits(“1234”); // speaks the digits 1, 2, 3 and 4.
$agi->saytime(); // speaks the current time.

  $agi->text2wav("These are some words eh?"); // speaks the phrase "These are some words eh?" using Festival.

  $agi->play("welcome"); // plays a file on the current channel.

  /*
  Plays the prompt "say-something", then records up to 10000 milliseconds of audio to the file "somefile.gsm"
  */
  $agi->recordfile("somefile","gsm",10000,"say-something");
  ?>

[/ul]

Output:

– Executing [3016@default:1] Answer(“SIP/1200-b6c0a098”, “”) in new stack
– Executing [3016@default:2] AGI(“SIP/1200-b6c0a098”, “saynumber.agi”) in new stack
– Launched AGI Script /var/lib/asterisk/agi-bin/saynumber.agi
– AGI Script saynumber.agi completed, returning 0
== Auto fallthrough, channel ‘SIP/1200-b6c0a098’ status is 'UNKNOWN’
asterisk*CLI>

and stil NOTHING.

Try activate the agi debug with the cli command “agi debug” to see if we get more informations about the script execution.

Regards.

Marco Bruni

the commands you are using are not vallid you should use these commands :smile:

#!/opt/lampp/bin/php

<?php require("phpagi.php"); $agi=new AGI(); $agi->say_number("1234"); // speaks the number 1234 $agi->say_digits("1234"); // speaks the digits 1, 2, 3 and 4. $agi->say_time(); // speaks the current time. $agi->text2wav("These are some words eh?"); // speaks the phrase "These are some words eh?" using Festival. $agi->stream_file('welcome');// plays a file on the current channel. see this page [asterisk.drunkcoder.com/agi.cgi](http://asterisk.drunkcoder.com/agi.cgi)

[quote=“sander4000”]the commands you are using are not vallid you should use these commands :smile:
[/quote]
NOT according to:

www.osdc.org.il/2006/html/Asterisk_AGI_Programming.ppt

No but when you use phpagi.php it is invalid php agi simplifies connection with asterisk it will convert the command

function say_phonetic($text, $escape_digits=’’)
{
return $this->evaluate(“SAY PHONETIC $text “$escape_digits””);
}

[quote=“sander4000”]No but when you use phpagi.php
[/quote]

In which directory do I put phpagi.php ?

I can’t find a manual how to properly install it. :frowning:

Just unpack in /var/lib/asterisk/agi-bin

and set file permissions to cmod 744 /var/lib/asterisk/agi-bin
for phpmanager to connect to the asterisk manager and make some custom settings for text2wave make a file phpagi.conf in /etc/asterisk

you can find a sample of that file in de doc folder when you unpack phpagi

[quote=“sander4000”]Just unpack in /var/lib/asterisk/agi-bin

and set file permissions to cmod 744 /var/lib/asterisk/agi-bin
for phpmanager to connect to the asterisk manager and make some custom settings for text2wave make a file phpagi.conf in /etc/asterisk

you can find a sample of that file in de doc folder when you unpack phpagi[/quote]

Thanks you for your comments.

(Dus hier ontmoeten we elkaar ook . :smile: )

/etc/asterisk/phpagi-bin

[asmanager]
server=localhost ; server to connect to
port=5038 ; default manager port
username=phpagi ; username for login
secret=myphpagisecret ; password for login

Do I need to put the username and secret from [asmanger] into manager.conf ?
(or there is no connection between the 2 ?)

/etc/asterisk/manager.conf

[phpagi] <----------------------:roll:
secret = myphpagisecret
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.0
permit=192.168.1.0/255/255/255.0
read=system,call,log,verbose,command,agent,user
write=system,call,log,verbose,command,agent,user :

yes just make the account so php manager can connect to the asteriskmanger :smile:
do you can make calls like the sample

<?php require_once('../phpagi-asmanager.php'); $number = '1234'; $asm = new AGI_AsteriskManager(); if($asm->connect()) { $call = $asm->send_request('Originate', array('Channel'=>"SIP/$number", 'Context'=>'default', 'Priority'=>1, 'Callerid'=>$number)); $asm->disconnect(); } ?>

ja hier ben ik ook zo af en toe aanwezig:)

When I run this script:

#!/opt/lampp/bin/php -q
<?php
  set_time_limit(30);
  require('phpagi.php');
  error_reporting(E_ALL);

  $agi = new AGI();
  $agi->answer();

  $cid = $agi->parse_callerid();
  $agi->text2wav("Hello, {$cid['name']}.");
  $agi->text2wav('Goodbye');
  $agi->hangup();
?>

I hear Hello and Goodbye.

I dont hear the callerid. :frowning:
It looks like that the callerid is not passed from asterisk to the script.

What is wrong in the script?

[ul]
AGI Tx >> 200 result=0
AGI Rx << STREAM FILE /var/spool/asterisk/tmp//text2wav_ace75969fc9b3a79aef4da4291ca0646 “” 0
– Playing ‘/var/spool/asterisk/tmp//text2wav_ace75969fc9b3a79aef4da4291ca0646’ (escape_digits=) (sample_offset 0)
AGI Tx >> 200 result=0 endpos=8627
AGI Rx << STREAM FILE /var/spool/asterisk/tmp//text2wav_6fc422233a40a75a1f028e11c3cd1140 “” 0
– Playing ‘/var/spool/asterisk/tmp//text2wav_6fc422233a40a75a1f028e11c3cd1140’ (escape_digits=) (sample_offset 0)
AGI Tx >> 200 result=0 endpos=7725
AGI Rx << HANGUP
AGI Tx >> 200 result=1
== Spawn extension (default, 3017, 2) exited non-zero on ‘SIP/1000-b6513238’
[/ul]