Hi, First off, can AGI scripts be created using PHP??.. This is where our skills are and since PHP can be run from a command line it would be easier to create and maintain.. I understand that AGI works using STDIN and STDOUT, so does that mean that I would simply "echo" the standard Asterisk commands that I wanted Asterisk to execute and it would process them? Are any call variables passed to the AGI script on execution? Where can I get a list of these? Finally, If I execute a call from within an AGI script, will the script continue processing when the call is hung up or terminated or would I have to use another AGI on the "h" extension to process post call operations? Thanks for your help..
WipeOut wrote:> First off, can AGI scripts be created using PHP??.. This is where our > skills are and since PHP can be run from a command line it would be > easier to create and maintain..Oh, flame war warning. There's been a lot of discussion on this before, mostly about the necessity to use PHP instead of <your favorit language here>. As I read the AGI docs, anything that you can start from a shell command with a #!/bin/sh or #!/usr/bin/perl construct works. I may be wrong, but otherwise start a /bin/sh and run PHP in there. Look at AGI samples in source code and the Asterisk::AGI perl library. Lots of good pointers to docs, faqs etc here: http://www.voip-info.org/tiki-index.php?page=Asterisk+agi> I understand that AGI works using STDIN and STDOUT, so does that mean > that I would simply "echo" the standard Asterisk commands that I wanted > Asterisk to execute and it would process them?No, there's a special set of commands you use. One of them lets you execute standard application commands you use in the dial plan, not the CLI commands as I understand.> Are any call variables passed to the AGI script on execution? Where can > I get a list of these?See docs pointed to from the Wiki. One of the sample scripts output all of the environment variables in AGI to stderr, even though I haven't been able to get the stderr output. Where do I read the STDERR channel?> Finally, If I execute a call from within an AGI script, will the script > continue processing when the call is hung up or terminated or would I > have to use another AGI on the "h" extension to process post call > operations?Good question. I can't answer. /O
You can run any agi script including pascal -----Original Message----- From: asterisk-users-admin@lists.digium.com [mailto:asterisk-users-admin@lists.digium.com] On Behalf Of WipeOut Sent: Friday, October 24, 2003 7:55 AM To: asterisk-users@lists.digium.com Subject: [Asterisk-Users] AGI questions.. Hi, First off, can AGI scripts be created using PHP??.. This is where our skills are and since PHP can be run from a command line it would be easier to create and maintain.. I understand that AGI works using STDIN and STDOUT, so does that mean that I would simply "echo" the standard Asterisk commands that I wanted Asterisk to execute and it would process them? Are any call variables passed to the AGI script on execution? Where can I get a list of these? Finally, If I execute a call from within an AGI script, will the script continue processing when the call is hung up or terminated or would I have to use another AGI on the "h" extension to process post call operations? Thanks for your help.. _______________________________________________ Asterisk-Users mailing list Asterisk-Users@lists.digium.com http://lists.digium.com/mailman/listinfo/asterisk-users
On Fri, 2003-10-24 at 06:54, WipeOut wrote:> Hi, > > First off, can AGI scripts be created using PHP??.. This is where our > skills are and since PHP can be run from a command line it would be > easier to create and maintain..You can use php, but php is just perl lite. if you do anything more than a trivial app, you will want to be in something more than php. Take for instance all the modules you have in CPAN that can deal with audio, databases and any number of odd things you need to have.> I understand that AGI works using STDIN and STDOUT, so does that mean > that I would simply "echo" the standard Asterisk commands that I wanted > Asterisk to execute and it would process them?Echo or print, just make sure you understand that you need to flush the input/output after each command.> Are any call variables passed to the AGI script on execution? Where can > I get a list of these?All of them are passed via the stdin at the beginning, some will vary depending on what is available on your channel. Write your script and check it out.> Finally, If I execute a call from within an AGI script, will the script > continue processing when the call is hung up or terminated or would I > have to use another AGI on the "h" extension to process post call > operations?If you are running agi commands instead of asterisk commands, you will receive a result code back from AGI that will indicate a hangup. At this point AGI will no longer accept commands, but your app is still running and can do post processing. In the apps my company has running, we use this time to clean up our session and send off files to be processed. -- Steven Critchfield <critch@basesys.com>
On Fri, 2003-10-24 at 05:54, WipeOut wrote:> First off, can AGI scripts be created using PHP??.. This is where our > skills are and since PHP can be run from a command line it would be > easier to create and maintain.. >Yes, you can use PHP just fine for AGI scripting. I recommend, however, that you use PHP version 4.3.0 or later, due to the updated CLI stuff. Feel free to contact me off-line if you'd like some examples. Jared Smith
Steven Critchfield wrote:>You can use php, but php is just perl lite. if you do anything more than >a trivial app, you will want to be in something more than php. Take for >instance all the modules you have in CPAN that can deal with audio, >databases and any number of odd things you need to have. > >I agree that perl is very powerful but our inhouse skills are in PHP.. So if possible I would prefer to do it in PHP..>Echo or print, just make sure you understand that you need to flush the >input/output after each command. > >can you explain what you mean by "flush the input/output"??>All of them are passed via the stdin at the beginning, some will vary >depending on what is available on your channel. Write your script and >check it out. > >Will do.. :)>If you are running agi commands instead of asterisk commands, you will >receive a result code back from AGI that will indicate a hangup. At this >point AGI will no longer accept commands, but your app is still running >and can do post processing. In the apps my company has running, we use >this time to clean up our session and send off files to be processed. > >Are there corresponding AGI commands for the Asterisk commands?? eg a command to dial instead or using the Asterisk "Dial" command.. Thanks for any help.. I am coming under pressure to get this system up and running.. :( Later..
> I understand that AGI works using STDIN and STDOUT, so does that mean > that I would simply "echo" the standard Asterisk commands that I wanted > Asterisk to execute and it would process them?be aware of that! don't use echo ... it's buffered and some commands don't get sent or sent too later. also using flush() to empty the buffer doesn't work ;) I had bad times on a php script that didn't got my commands via echo().... use file descriptors for it (stderr & stdin). but... at least on php 4.3.3 (but think there's from 4.3) php , cli version only, as a nice feature ... as you fire up a script from cli, php is kind enough to provide you with 2 special, alreay open file descriptors: STDIN & STDOUT ... you can do things like fputs(STDOUT,$str,$strlen) without doing annoying fopens & fcloses ;) a sort of streams always open during the script execution, and works great here ;) matteo. -- Brancaleoni Matteo <mbrancaleoni@espia.it> Espia - Emmegi Srl