A note to all those who are avoiding writing up an AGI becasue it looks two complicated.. I have just written up my first and its awesome.. It makes Asterisk open to all sorts of possibilities.. let your imagination run wild.. I put off writing an AGI script because a) I could not find any docs b) it looked like the only way to do it was perl and I know nothing about perl and c) I am not a coder, more a simple sysadmin.. Eventually I decided to give it a try, and seeing as the language I know the best is PHP I decided to do my script in PHP.. The truth of the matter is that once you have worked out how to get your variables from Asterisk into a usable array or whatever you are happy using the rest is a piece of cake.. It goes without saying that what I have done is stupidly simple but for a non coder its still a giant achivement.. So all I can say is thanks to the Mark and the team for dreaming up AGI... To those who are putting off giving it a go, don't!!.. Dive in and give it a try.. PS. I won't be much help to anyone on AGI related questions, the list is still you best bet, this was just to hopefully inspire others to give it a try..
----- Original Message ----- From: "WipeOut" <wipe_out@users.sourceforge.net> To: <asterisk-users@lists.digium.com> Sent: Tuesday, November 25, 2003 2:14 PM Subject: [Asterisk-Users] AGI Rocks!! (A happy camper)> A note to all those who are avoiding writing up an AGI becasue it looks > two complicated.. > > I have just written up my first and its awesome.. It makes Asterisk open > to all sorts of possibilities.. let your imagination run wild.. > > I put off writing an AGI script because a) I could not find any docs b) > it looked like the only way to do it was perl and I know nothing about > perl and c) I am not a coder, more a simple sysadmin.. > > Eventually I decided to give it a try, and seeing as the language I know > the best is PHP I decided to do my script in PHP.. The truth of the > matter is that once you have worked out how to get your variables from > Asterisk into a usable array or whatever you are happy using the rest is > a piece of cake.. > > It goes without saying that what I have done is stupidly simple but for > a non coder its still a giant achivement.. > > So all I can say is thanks to the Mark and the team for dreaming up > AGI... To those who are putting off giving it a go, don't!!.. Dive in > and give it a try.. >I believe I read Mark or someone say many of the builtin apps would become AGI scripts in the future. Given how many people cry over the voicemail layout, I've been thinking about writing an AGI script for voicemail. PHP would be my first choice, unless I can find my perl book. Maybe I will go hack something out... Has anyone already started work on a to be released script like this? ----- Andrew Thompson
I was just looking at AGI with PHP myself. I just have a real dumb question. How does Linux know to send $stdout(or echo) to *? What if there are other apps open as well waiting for input. WOn't they get the output? Also, how does the AGI know to read from $stdin is * input? Costas ---------- Original Message ---------------------------------- From: WipeOut <wipe_out@users.sourceforge.net> Reply-To: asterisk-users@lists.digium.com Date: Tue, 25 Nov 2003 19:14:48 +0000>A note to all those who are avoiding writing up an AGI becasue it looks >two complicated.. > >I have just written up my first and its awesome.. It makes Asterisk open >to all sorts of possibilities.. let your imagination run wild.. > >I put off writing an AGI script because a) I could not find any docs b) >it looked like the only way to do it was perl and I know nothing about >perl and c) I am not a coder, more a simple sysadmin.. > >Eventually I decided to give it a try, and seeing as the language I know >the best is PHP I decided to do my script in PHP.. The truth of the >matter is that once you have worked out how to get your variables from >Asterisk into a usable array or whatever you are happy using the rest is >a piece of cake.. > >It goes without saying that what I have done is stupidly simple but for >a non coder its still a giant achivement.. > >So all I can say is thanks to the Mark and the team for dreaming up >AGI... To those who are putting off giving it a go, don't!!.. Dive in >and give it a try.. > >PS. I won't be much help to anyone on AGI related questions, the list is >still you best bet, this was just to hopefully inspire others to give it >a try.. > >_______________________________________________ >Asterisk-Users mailing list >Asterisk-Users@lists.digium.com >http://lists.digium.com/mailman/listinfo/asterisk-users >-- Costas Menico Meezon Software Corp 201-224-8111 costas@meezon.com --
On Tuesday 25 November 2003 13:54, Andrew Thompson wrote:> I believe I read Mark or someone say many of the builtin apps would > become AGI scripts in the future.Somehow, I doubt it. AGI takes more resources to execute than an application, as it needs to fork and execute another application, which in most cases is a scripting language, which means that a large interpreter must be loaded into memory for each invocation (i.e. each channel). Applications, on the other hand, execute in the same thread as the channel itself and do not take up any significant amount of memory. Further, the application code is shared between all channels, further decreasing the necessary space to execute. Indeed, not having to fork for each channel also makes applications faster than AGI. AGI cannot be beat in terms of rapid application development, or in some of the complexities of various AGI applications. What I would believe, though, is that some of the applications in the future may get AGI commands, such that it becomes easier to invoke them than invoking the application with EXEC (i.e. "SAY UNIXTIME n" instead of "EXEC SayUnixTime(n)"). -Tilghman
Reading the code is easy. Finding the correct code to read is the tough part. Thanks for the overview. Now it make sense how the mechanism of AGI communication works, via stdin/stdout. ---------- Original Message ---------------------------------- From: Steven Critchfield <critch@basesys.com> Reply-To: asterisk-users@lists.digium.com Date: Tue, 25 Nov 2003 15:42:40 -0600>On Tue, 2003-11-25 at 14:02, costas wrote: >> I was just looking at AGI with PHP myself. I just have a real dumb question. How does Linux know to send $stdout(or echo) to *? What if there are other apps open as well waiting for input. WOn't they get the output? >> >> Also, how does the AGI know to read from $stdin is * input? > >I understand that sometimes C can be daunting to a non programmer, but >this is a fairly easy look at the source question. I'll help you out on >this one. > >In /usr/src/asterisk/apps/app_agi.c you will find a function >load_module. In fact, you will find this with all builtin applications. >Near the end of this function you will see ... > return ast_register_application(app, agi_exec, synopsis, descrip); >The action here should be fairly easy to understand. It registers an >application with each of those arguments. Of interest is the agi_exec >function as it is what asterisk will call when launching the AGI >application. > >At this point it may seem odd that all that agi_exec does is call >agi_exec_full, but it is due to the eagi application being intertwined >into agi. In agi_exec_full, you scan through it, you will find >launch_script. This is where your application gets launched and >connected to asterisk. > >In launch_script you will find a section like this. > pid = fork(); > if (pid < 0) { > ast_log(LOG_WARNING, "Failed to fork(): %s\n", strerror(errno)); > return -1; > } > if (!pid) { > /* Redirect stdin and out, provide enhanced audio channel if desired */ > dup2(fromast[0], STDIN_FILENO); > dup2(toast[1], STDOUT_FILENO); > > >So this is how it reconnects the stdin and stdout to asterisk. > >> ---------- Original Message ---------------------------------- >> From: WipeOut <wipe_out@users.sourceforge.net> >> Reply-To: asterisk-users@lists.digium.com >> Date: Tue, 25 Nov 2003 19:14:48 +0000 >> >> >A note to all those who are avoiding writing up an AGI becasue it looks >> >two complicated.. >> > >> >I have just written up my first and its awesome.. It makes Asterisk open >> >to all sorts of possibilities.. let your imagination run wild.. >> > >> >I put off writing an AGI script because a) I could not find any docs b) >> >it looked like the only way to do it was perl and I know nothing about >> >perl and c) I am not a coder, more a simple sysadmin.. >> > >> >Eventually I decided to give it a try, and seeing as the language I know >> >the best is PHP I decided to do my script in PHP.. The truth of the >> >matter is that once you have worked out how to get your variables from >> >Asterisk into a usable array or whatever you are happy using the rest is >> >a piece of cake.. >> > >> >It goes without saying that what I have done is stupidly simple but for >> >a non coder its still a giant achivement.. >> > >> >So all I can say is thanks to the Mark and the team for dreaming up >> >AGI... To those who are putting off giving it a go, don't!!.. Dive in >> >and give it a try.. >> > >> >PS. I won't be much help to anyone on AGI related questions, the list is >> >still you best bet, this was just to hopefully inspire others to give it >> >a try.. >> > >> >_______________________________________________ >> >Asterisk-Users mailing list >> >Asterisk-Users@lists.digium.com >> >http://lists.digium.com/mailman/listinfo/asterisk-users >> > >> >> -- >> Costas Menico >> Meezon Software Corp >> 201-224-8111 >> costas@meezon.com >> >> -- >> _______________________________________________ >> Asterisk-Users mailing list >> Asterisk-Users@lists.digium.com >> http://lists.digium.com/mailman/listinfo/asterisk-users >-- >Steven Critchfield <critch@basesys.com> > >_______________________________________________ >Asterisk-Users mailing list >Asterisk-Users@lists.digium.com >http://lists.digium.com/mailman/listinfo/asterisk-users >-- Costas Menico Meezon Software Corp 201-224-8111 costas@meezon.com --