[asterisk-users] Trouble Playing message file via Perl AGI

Mike Diehl mdiehl at diehlnet.com
Wed Jul 23 16:22:37 CDT 2008


David,

What you sent me is almost exactly what I had, which indicated that that part 
of my code was correct.  So, I moved that block of code to the top of my 
program and it worked.  Eventually, I found a debug print() statement that I 
had forgotten to take out.  Once it was gone, my code worked as expected.  
Thank you for your time.

Mike.

On Wednesday 23 July 2008 01:48:14 pm David Van Ginneken wrote:
> Mike Diehl wrote:
> > Hi all,
> >
> > I'm trying to build an IVR using the Perl AGI module at
> > http://search.cpan.org/~jamesgol/asterisk-perl-0.10/lib/Asterisk/AGI.pm
> >
> > But, I'm having trouble getting my program to play a message and wait for
> > a keystroke.
> >
> > I am able to use this code to play the file, so I know that the $msg
> > variable points to a valid sound file:
> >
> > $result = $agi->exec("background $msg");
> >
> > But of course, this doesn't allow me to capture any keypresses.  So I
> > tried this:
> >
> > $agi->stream_file($msg, "0123456789", 0);
> >
> > The console indicates that it's playing the message, but it then skips to
> > the next AGI instruction and nothing gets played.
> >
> > Then I tried to use the get_data() method.  It turns out that I had to
> > put two of them in my code, but then the timeout doesn't work and it
> > doesn't capture any keypresses:
> >
> > $result = $agi->get_data($msg, 120000, 1);
> > $result = $agi->get_data($msg, 120000, 1);
> >
> > Finally, I tried to use the get_option() method that was documented in
> > the module POD file; Perl complains that the method isn't defined:
> >
> > $result = $agi->get_option($msg, "12345", 10000);
> >
> > So, what am I missing?  I know this works; too many people are doing it. 
> > Any ideas?
> >
> > TIA,
>
> $agi->get_data is likely what you are looking for. I'm using it
> successfully in both standard and FastAGI scripts.
>
> With this sample script:
> #!/usr/bin/perl
> use Asterisk::AGI;
> use strict;
> my $AGI = new Asterisk::AGI;
> my %input = $AGI->ReadParse();
> my $digits = $AGI->get_data('tt-monkeys', 10000, 1);
> $AGI->verbose("We Received $digits",3);
> exit;
>
> The CLI outputs:
> **
> -- Executing [agi-test at default:1] AGI("SIP/1223-090046a8", "test.agi")
> in new stack
> -- Launched AGI Script /var/lib/asterisk/agi-bin/test.agi
> -- <SIP/1223-090046a8> Playing 'tt-monkeys' (language 'en')
> -- test.agi: We Received 4
> -- AGI Script test.agi completed, returning 0
>
> When I press 4 when listening to tt-monkeys.
>
>
> Hope this helps.
>
> - Dave
>
>
>
> _______________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>
> AstriCon 2008 - September 22 - 25 Phoenix, Arizona
> Register Now: http://www.astricon.net
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-users



-- 
Mike Diehl



More information about the asterisk-users mailing list