That's getting pretty close - thanks for that. I just couldn't find any decent info on the web about working with AGI.
regards, PaulH ----- Original Message ----- From: "Michael Collins" <[EMAIL PROTECTED]> To: "Asterisk Users Mailing List - Non-Commercial Discussion" <[email protected]> Sent: Wednesday, March 01, 2006 6:25 AM Subject: RE: [Asterisk-Users] Re: Asterisk Question > > -----Original Message----- > > From: [EMAIL PROTECTED] [mailto:asterisk-users- > > [EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] > > Sent: Monday, February 27, 2006 7:53 PM > > To: Asterisk Users Mailing List - Non-Commercial Discussion > > Subject: Re: [Asterisk-Users] Re: Asterisk Question > > > > > > I was going to see if I can execute a bash script as an AGI - just > looking > > around the internet for examples at the moment. > > Anybody got an example spare? > > I'm just a bit stuck on how to start this, but I am quite comfortable > > writing asterisk dialplan stuff and bash scripts.... > > > > later, > > > > PaulH > > > > Paul, > > I'm a Perl guy myself. Here's a simple dialplan extension and AGI > script written in Perl and using the very cool Asterisk::AGI module: > > ; AGI test > exten => 555,1,Noop(Starting AGI test) > exten => 555,n,Answer > exten => 555,n,Wait(1) > exten => 555,n,Playback(beep) > exten => 555,n,AGI(agi_var_test.pl) > exten => 555,n,SayDigits(${EXTERN_VAR}) > exten => 555,n,Wait(1) > exten => 555,n,Playback(beep) > exten => 555,n,Hangup > > > Here's the Perl script: > > #!/usr/bin/perl > # > # agi_var_test.pl > # > # Reads in info from file /etc/group > # assigns asterisk GID to Asterisk variable EXTERN_VAR > # > use strict; > use warnings; > use Asterisk::AGI; > > # the AGI object > my $agi = new Asterisk::AGI; > > # pull AGI variables into %input > my %input = $agi->ReadParse(); > > my $infile = '/etc/group'; > open(FILEIN,"<",$infile) or die "$infile - $!\n"; > while(<FILEIN>) { > chomp; > next unless m/^asterisk/; > my @REC = split ":",$_; > print STDERR "agi_var_test.pl: Setting EXTERN_VAR to $REC[2]\n"; > $agi->set_variable("EXTERN_VAR", $REC[2]); > last; > } # while(<FILEIN>) > close(FILEIN); > > > Basically the script just parses /etc/group until it finds the asterisk > entry. It then parses the data line and extracts the GID. Finally, it > prints the value to STDERR (for debugging purposes) and then assigns the > value to EXTERN_VAR. > > This is more a proof-of-concept than anything else, but it does show the > value of AGI and Asterisk::AGI. > > -MC > _______________________________________________ > --Bandwidth and Colocation provided by Easynews.com -- > > Asterisk-Users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users > > _______________________________________________ --Bandwidth and Colocation provided by Easynews.com -- Asterisk-Users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
