#!/usr/bin/perl use Asterisk::AGI; $AGI = new Asterisk::AGI; my $callerid=$ARGV[0]; my @trusted=("1112223333","2223334444"); my $size= scalar @trusted; my $match=0; while ($size>0) { $size--; if ($callerid eq $trusted[$size]) { $match=1; } } if ($match==1) { $AGI->exec('Festival', '"Please. Enter. the. source. number"'); my %input = $AGI->ReadParse(); my $finished = 0; while (!$finished) { my $input = chr($AGI->wait_for_digit('5000')); if ($input =~ /^[0-9\*\#]$/) { if ($input =~ /^[\*\#]$/) { $x++; if ($x > 10) { $finished = 1; } else { $code.= ''; } } else { $code .= $input; } } if ( length($code) > 10) { $finished = 1; } } $AGI->exec('Festival', '"Please. Enter. the. destination. number"'); `echo "$code">/tmp/code`; my $finished2 = 0; `echo "here">/tmp/code`; while (!$finished2) { my $input = chr($AGI->wait_for_digit('5000')); if ($input =~ /^[0-9\*\#]$/) { if ($input =~ /^[\*\#]$/) { $x2++; if ($x2 > 10) { $finished2 = 1; } else { $code2.= ''; } } else { $code2 .= $input; } } if ( length($code2) > 10) { $finished2 = 1; } } $AGI->setcallback(\&callback); $AGI->exec('Festival', '"I will now dial "'); $AGI->exec('Festival', $code2); $AGI->exec('Festival', '"with"'); $AGI->exec('Festival', $code); #Your IAX/SIP dialing instruction go here... For Example: #$code2="IAX2/1234\@iax2provider/$code2"; #$code2="SIP/$code2\@sipprovider"; $code2=""; $AGI->set_callerid($code); $AGI->exec('Dial', $code2); } else { $AGI->exec('Festival', '"Unauthorized. Attempt logged."'); } sub callback(){ warn "The call has ended\n"; set_context($context); exit; }