Perfection! PaulH
On Tue, 2006-02-28 at 22:24 -0700, Darren Wiebe wrote: > my ( $var1, $var2, $var3 ) = > @ARGV; > > and so on and so forth. > > Good Luck > > Darren Wiebe > [EMAIL PROTECTED] > > Paul Hales wrote: > > >Thanks for this example - it has really got me started! > > > >Short question - how can I put a variable into my perl script? > > > >I imagine it's something like > >exten => 780,1,AGI(agi_ret_val2.pl|${back}) > > > >But how can I get my perl script to pick this value up? > > > >Again - thanks to everyone who has helped me with this. > > > >later, > > > >PaulH > > > >On Tue, 2006-02-28 at 11:25 -0800, Michael Collins wrote: > > > > > >>>-----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 > > > > > > _______________________________________________ --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