[Asterisk-Users] Removing "-" (Dash) from Dialed Numbers

Nathan Pralle tarsi at binhost.com
Mon Sep 26 13:18:09 MST 2005


>     I am trying to enable dial-by-email by using LDAPget to query an
>     Active Directory server.  I've got it retrieving the phone number
>     fine.  Unforunately, the numbers stored in active directory are
>     either in the format:  (xxx) xxx-xxxx or xxx-xxx-xxxx.   Is there
>     any way to parse characters out of the dialed phone number so that I
>     only end up with digits (remove spaces, parenthesis and dashes)?  
>      From there, my outbound routes can take care of where to send the
>     call.

Scott,

This would be darned easy to do with the AGI and a perl script.

IE:

exten => _X.,1,agi,fixnumbers|${MyNumber}
exten => _X.,2,Dial(ZAP/g0/1${MyNumber})

Then, in a perl script called "fixnumbers" and inside the agi-bin directory:

########## START CODE #############
#!/usr/bin/perl -w
use strict;
use Asterisk::AGI;
$AGI = new Asterisk::AGI;
my %input = $AGI->ReadParse();

my $number=$ARGV[0];
$number=~s/-//g;
$number=~s/ //g;
$number=~s/\(//g;
$number=~s/\)//g;

print $AGI->set_variable('MyNumber',"$number");

exit;

####### END CODE ########

Nathan


-- 
-------------------------------------
Nathan E. Pralle
Give the Director a Serpent Deflector
www.nathanpralle.com
-------------------------------------



More information about the asterisk-users mailing list