All pastes #26468 Raw Edit

Anonymous

public text v1 · immutable
#26468 ·published 2005-10-24 10:54 UTC
rendered paste body
#!/usr/bin/perl
#
# Simple agi example that says the callerid and/or dnis
#
# Written by: James Golovich <james@gnuinter.net>
#


use Asterisk::AGI;

$AGI = new Asterisk::AGI;

my %input = $AGI->ReadParse();

$AGI->verbose("testing..............");
$AGI->verbose($ARGV[0]);

$vmconf = $ARGV[0];
$exten = $ARGV[1];
$pwd = $ARGV[2];

$AGI->verbose($exten);
$AGI->verbose($pwd);

open VMCONF,"<$vmconf";
        @vmconf_lines = <VMCONF>;
close VMCONF
&error_msg("Cannot open $vmconf file read only.") if $vmconf_lines eq -1;

foreach (@vmconf_lines){
        next if $_ !~ /^\d/;
        $_ =~ s/\s//iog;
        $_ =~ s/=>/=/iog;
        $_ =~ s/=/\,/;
        (@line_args) = split(/\,/,$_);
#       $AGI->verbose($_);
#       $AGI->verbose($line_args[0]);
if ($exten eq $line_args[0]){

$AGI->verbose($pwd);
$AGI->verbose($line_args[1]);

if ($pwd eq $line_args[1]){
                        $AGI->set_variable('result','1');
                } else {
                        $AGI->set_variable('result','0');
                }
        }
}

exit;

sub error_msg(){
        my($err_msg) = @_;
        $AGI->verbose($err_msg);
        $AGI->hangup();
        die $err_msg;
}


#if (my $callerid = $input{'callerid'}) {
#       $AGI->stream_file('agi-yourcalleridis');
#       $AGI->say_digits($callerid);
#}
#if (my $dnis = $input{'dnid'}) {
#       $AGI->stream_file('agi-dnisis');
#       $AGI->say_digits($dnis);
#}

exit;