[Asterisk-Users] AGI Questions
Hi I'm trying to integrate Arabic numbering in asterisk I've been using agi->stream_file(FILENAME) , but it seems that it doesn't like to send the filename with path Like agi->stream_file(ar/filename) Anyone knows if it is built this way? Cheers ___ --Bandwidth and Colocation sponsored by Easynews.com -- Asterisk-Users mailing list Asterisk-Users@lists.digium.com http://lists.digium.com/mailman/listinfo/asterisk-users To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [Asterisk-Users] AGI questions..
> 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 <[EMAIL PROTECTED]> Espia - Emmegi Srl ___ Asterisk-Users mailing list [EMAIL PROTECTED] http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [Asterisk-Users] AGI questions..
Philipp von Klitzing wrote: Hi! Maybe you'll find his php example to be helpful: http://www.junghanns.net/asterisk/page14.html Good call... I am looking at it now.. Later.. ___ Asterisk-Users mailing list [EMAIL PROTECTED] http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [Asterisk-Users] AGI questions..
On Fri, 24 Oct 2003, Jared Smith wrote: > On Fri, 2003-10-24 at 09:04, 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 don't mean to start a flame war, but it's opinions like this that > drive me nuts... (And just to be fair Steven, I *almost always* agree > with your opinions posted to this list. This one just happens to get on > my nerves.) Just because you *obviously* prefer Perl, doesn't mean you > have to belittle PHP. WipeOot *obviously* wants to use PHP. So (in my > humble opinion) we ought to either help him figure out how to do it in > PHP, or keep our mouths shut. One of the great things about PHP is that you can just get one download, compile and install it and it has everything you will probably want for web use built in. No need to mess around downloading lots of CPAN things. Okay there might not be as many libraries available, but for web stuff it keeps life simple. Personally I write in either Perl or PHP depending on the job. Programs I run from the command line are written in Perl and web things in PHP. However I feel both products have things to recommend them. In PHP functions and classes are defined in a more conventional way, none of this pass a stack and pop things off to get your function arguments. Perl feels like it was more carefully thought out. Everything is done in relatively generic and flexible ways. Database support is just fine in PHP but audio would admittedly be less supported. Michael ___ Asterisk-Users mailing list [EMAIL PROTECTED] http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [Asterisk-Users] AGI questions..
On Fri, 2003-10-24 at 10:36, WipeOut wrote: > 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.. If you know php, then you are 7/10ths of the way to knowing perl fairly well. > >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"?? Familiarize yourself with buffered output. Basically, buffered output is there so the kernel can get a large enough block of data to work with to be efficient when it does the context switch to the app receiving the data. The problem is these buffers are usually around a half k or more in size and not line oriented. You need to flush the buffer through to the other application(AGI) to make sure it gets the whole line to process with the line terminator so AGI knows to start working on the command. the flush command takes care of that for the buffers you are writing to. I'm not too sure about the buffers you will be reading from. > >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.. Yes and no. You can set the priority, extension, and context of the dialplan to resume at when you exit. You can even dial out, but at the moment you dial, the AGI app will no longer be in control. > Thanks for any help.. I am coming under pressure to get this system up > and running.. :( > > Later.. > > > ___ > Asterisk-Users mailing list > [EMAIL PROTECTED] > http://lists.digium.com/mailman/listinfo/asterisk-users -- Steven Critchfield <[EMAIL PROTECTED]> ___ Asterisk-Users mailing list [EMAIL PROTECTED] http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [Asterisk-Users] AGI questions..
On Fri, 2003-10-24 at 10:49, Jared Smith wrote: > On Fri, 2003-10-24 at 09:04, 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 don't mean to start a flame war, but it's opinions like this that > drive me nuts... (And just to be fair Steven, I *almost always* agree > with your opinions posted to this list. This one just happens to get on > my nerves.) Just because you *obviously* prefer Perl, doesn't mean you > have to belittle PHP. WipeOot *obviously* wants to use PHP. So (in my > humble opinion) we ought to either help him figure out how to do it in > PHP, or keep our mouths shut. No need to think this will start a flame war. I think calling it Perl lite is justified. It does a lot of what perl does, but without some of the bloat that comes with perl. I write all our web apps in php specifically for the speed in which I can write them, and the speed in which they run. I write non web app applications in perl because of the extended functionality. I think calling it perl lite is less belittling than the comments I hear regularly which is perl--. It has been commented by many people out side of this forum that php tries real hard to not reinvent perl, but they tend to do it that way anyways after a while because it is easier. I don't know if that is true or not. I do see how easy it is to copy php code to perl and barely have to change anything to make it function. This is because perl, for the most part, is a super set of php. As for the helping WipeOut, I thought I was, I answered his questions. I'm about to answer more of them. > And, for what it's worth, PHP also has a large code base to deal with > audio, databases, and "any number of odd things". While they might not > have as much user-contributed code as CPAN, PHP is certainly a lot more > than just "perl lite". > > /me runs off to put on some flame-resistant clothing No need. I have left the flame thrower in my basement at home next to the metal work I have been banging on lately. So funny how getting a new hobby has helped my mood and patience. -- Steven Critchfield <[EMAIL PROTECTED]> ___ Asterisk-Users mailing list [EMAIL PROTECTED] http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [Asterisk-Users] AGI questions..
Hi! Maybe you'll find his php example to be helpful: http://www.junghanns.net/asterisk/page14.html Tip of the day [2003-06-4] capi Callback Just call your asterisk box with your mobile, let it ring and hang up. Asterisk will call you back at once and provide you with a normal dialtone (early B3). [capiin] exten => 1234/01606,1,Wait,1 exten => 1234/01606,2,AGI,callback.agi exten => 1234/01606,3,Hangup [capidialtone] exten => s,1,Dial,CAPI/@1234:b exten => s,2,Hangup < ? p h p ob_implicit_flush(true); set_time_limit(0); $err=fopen("php://stderr","w"); $in = fopen("php://stdin","r"); while (!feof($in)) { $temp = str_replace("\n","",fgets($in,4096)); $s = split(":",$temp); $agi[str_replace("agi_","",$s[0])] = trim($s[1]); if (($temp == "") || ($temp == "\n")) { break; } } $cf = fopen("/home/kapejod/pbx/var/spool/asterisk/outgoing/cb".$agi["callerid"], "w+"); fputs($cf,"Channel: CAPI/".$agi["extension"].":".$agi["callerid"]."\n"); fputs($cf,"Context: capidialtone\n"); fputs($cf,"Extension: s\n"); fputs($cf,"SetVar: CALLERIDNUM=".$agi["extension"]."\n"); fputs($cf,"MaxRetries: 2\n"); fputs($cf,"RetryTime: 10\n"); fclose($cf); fclose($in); fclose($err); ? > ___ Asterisk-Users mailing list [EMAIL PROTECTED] http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [Asterisk-Users] AGI questions..
Jarad, I would be interested in one or 2 of your examples to get an idea of how to get started. Thanks, Robert Friedrichshafen, Germany > 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 > > > > ___ > Asterisk-Users mailing list > [EMAIL PROTECTED] > http://lists.digium.com/mailman/listinfo/asterisk-users > ___ Asterisk-Users mailing list [EMAIL PROTECTED] http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [Asterisk-Users] AGI questions..
Are there corresponding AGI commands for the Asterisk commands?? eg a command to dial instead or using the Asterisk "Dial" command.. Not one-to-one correspondence. Some of the basic ones you need are there. ANSWER AUTOHANGUP CHANNEL STATUS [] EXEC GET DATA [] [] GET VARIABLE HANGUP [] RECEIVE CHAR RECORD FILE [BEEP] SAY DIGITS SAY NUMBER SEND IMAGE SEND TEXT "" SET CALLERID SET CONTEXT SET EXTENSION SET PRIORITY SET VARIABLE STREAM FILE TDD MODE VERBOSE WAIT FOR DIGIT See here: http://www.voip-info.org/tiki-index.php?page=Asterisk+AGI for an overview On that page you'll find a pointer to http://home.cogeco.ca/~camstuff/agi.html which is a good, but a bit out of date, documentation. Here you'll find examples and advice on how to programme in C, Java, perl and python - not PHP, but I think you'll grasp the stuff anyway and is able to adopt it to PHP. One of the commands is EXEC which deliver the power of all your registred applications. I believe that there are samples in the distribution as well as in the Perl library, which you'll have to download from another site (referenced on the Wiki). Even though you won't develop in Perl, those are good examples to read through. I hope this helps. When you're done, I hope that you add some experiences and examples on how to do AGI apps in PHP to the wiki :-) /O ___ Asterisk-Users mailing list [EMAIL PROTECTED] http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [Asterisk-Users] AGI questions..
On Fri, 2003-10-24 at 09:04, 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 don't mean to start a flame war, but it's opinions like this that drive me nuts... (And just to be fair Steven, I *almost always* agree with your opinions posted to this list. This one just happens to get on my nerves.) Just because you *obviously* prefer Perl, doesn't mean you have to belittle PHP. WipeOot *obviously* wants to use PHP. So (in my humble opinion) we ought to either help him figure out how to do it in PHP, or keep our mouths shut. And, for what it's worth, PHP also has a large code base to deal with audio, databases, and "any number of odd things". While they might not have as much user-contributed code as CPAN, PHP is certainly a lot more than just "perl lite". /me runs off to put on some flame-resistant clothing Jared Smith ___ Asterisk-Users mailing list [EMAIL PROTECTED] http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [Asterisk-Users] AGI questions..
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.. ___ Asterisk-Users mailing list [EMAIL PROTECTED] http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [Asterisk-Users] AGI questions..
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 ___ Asterisk-Users mailing list [EMAIL PROTECTED] http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [Asterisk-Users] AGI questions..
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 <[EMAIL PROTECTED]> ___ Asterisk-Users mailing list [EMAIL PROTECTED] http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [Asterisk-Users] AGI questions..
Hi, I'm trying to use the h extension for postprocessing, but for now I couldnt do it, it runs, but lacks debuging output; well, to tell you the thruth, I didnt try to hard to make it work from the "h" extension. What I do is this: the script is for controling prepaid accounts. I do the post-call processing at the beginning of the script (that is, calculate the cost of the pending processing calls and substract the amount to the account, *before* placing a new call). So, the last call is not processed until the user tries to make another one. It works perfectly well in this way, but I think its cleaner to calculate the cost after the user hangs ups. > >Hi, > > > >I use asterisk-perl and when I execute Dial from my script, it stops > >procesing it and I cannot perform cleanups or post call operations in that > >script. It would be very nice to take the control back from the script.. > > So how do you do your post call operations?? do you use another AGI > script on the "h" extension? > Nicolas Gudino House Internet S.R.L. Buenos Aires - Argentina ___ Asterisk-Users mailing list [EMAIL PROTECTED] http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [Asterisk-Users] AGI questions..
Nicolas Gudino wrote: Hi, I use asterisk-perl and when I execute Dial from my script, it stops procesing it and I cannot perform cleanups or post call operations in that script. It would be very nice to take the control back from the script.. So how do you do your post call operations?? do you use another AGI script on the "h" extension? ___ Asterisk-Users mailing list [EMAIL PROTECTED] http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [Asterisk-Users] AGI questions..
Hi, I use asterisk-perl and when I execute Dial from my script, it stops procesing it and I cannot perform cleanups or post call operations in that script. It would be very nice to take the control back from the script.. > >> 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. > > This is an important question I need answered for my system.. > -- Nicolas Gudino House Internet S.R.L. Buenos Aires - Argentina ___ Asterisk-Users mailing list [EMAIL PROTECTED] http://lists.digium.com/mailman/listinfo/asterisk-users
RE: [Asterisk-Users] AGI questions..
You can run any agi script including pascal -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of WipeOut Sent: Friday, October 24, 2003 7:55 AM To: [EMAIL PROTECTED] 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 [EMAIL PROTECTED] http://lists.digium.com/mailman/listinfo/asterisk-users ___ Asterisk-Users mailing list [EMAIL PROTECTED] http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [Asterisk-Users] AGI questions..
Olle E. Johansson wrote: Oh, flame war warning. There's been a lot of discussion on this before, mostly about the necessity to use PHP instead of . Thanks for the warning, but is PHP.. :) 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. A PHP script can have #!/usr/bin/php (on my server anyway) and it will execute from a command line just like any other so you don't have to use a sh shell first.. :) 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 Thanks, looking at the page now... 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. I guess that would be the "exec" command?? By the description on the page * "exec*: Executes a given Application".. 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. This is an important question I need answered for my system.. Later.. ___ Asterisk-Users mailing list [EMAIL PROTECTED] http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [Asterisk-Users] AGI questions..
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 . 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 ___ Asterisk-Users mailing list [EMAIL PROTECTED] http://lists.digium.com/mailman/listinfo/asterisk-users
[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 [EMAIL PROTECTED] http://lists.digium.com/mailman/listinfo/asterisk-users