[asterisk-users] HELP - Client wants to reverse Asterisk Functionality
Danny Nicholas
danny at debsinc.com
Wed Jul 20 17:56:00 CDT 2011
-----Original Message-----
From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Steve Edwards
Sent: Wednesday, July 20, 2011 3:19 PM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] HELP - Client wants to reverse Asterisk
Functionality
On Wed, 20 Jul 2011, Danny Nicholas wrote:
> I?m putting Asterisk in to replace an existing IVR and that PBX system
> uses * to terminate number input instead of #.
How about an AGI executing some mix of get data, get option, stream file, or
wait for digit and accumulate the digits yourself.
--
Great idea Steve (what else should I expect). I modified the agi-test.agi
that comes in the can to do just this, it just doesn't terminate when the
user presses * (still have to wait for the timeout)
Here it is if anyone cares -
#!/usr/bin/perl
use strict;
$|=1;
# Setup some variables
my %AGI; my $tests = 0; my $fail = 0; my $pass = 0;
my ($retvar, $rettime, $retlen) = @ARGV;
if (! $retvar) {
$retvar='digitacct';
$retlen=16;
$rettime=10000;
}
if (! $retlen) {
$retlen=16;
$rettime=10000;
}
if (! $rettime) {
$rettime=10000;
}
while(<STDIN>) {
chomp;
last unless length($_);
if (/^agi_(\w+)\:\s+(.*)$/) {
$AGI{$1} = $2;
}
}
print STDERR "AGI Environment Dump:\n";
foreach my $i (sort keys %AGI) {
print STDERR " -- $i = $AGI{$i}\n";
}
sub checkresult {
my ($res) = @_;
my $retval;
$tests++;
chomp $res;
if ($res =~ /^200/) {
$res =~ /result=(-?\d+)/;
if (!length($1)) {
print STDERR "FAIL ($res)\n";
$fail++;
} else {
print STDERR "PASS ($1)\n";
$pass++;
}
} else {
print STDERR "FAIL (unexpected result '$res')\n";
$fail++;
}
}
print STDERR "1. Testing 'get data'...";
print "GET DATA beep $rettime $retlen\"\"\n";
my $result = <STDIN>;
&checkresult($result);
my $nresult=$result;
#my $rdigit=' ';
#while (length($nresult)<16 && $rdigit ne '*') {
# print "WAIT DTMF 4000\n";
# $rdigit=<STDIN>;
# &checkresult($rdigit);
# $nresult=$nresult.$rdigit if $nresult;
# $nresult=$rdigit if !$nresult;
# }
print STDOUT "SET VARIABLE $retvar $nresult\n";
my $result2 = <STDIN>;
&checkresult($result2);
print STDERR "================== Complete ======================\n";
print STDERR "$tests tests completed, $pass passed, $fail failed\n";
print STDERR "==================================================
More information about the asterisk-users
mailing list