Scott Miller
2005-Sep-23 12:22 UTC
[Asterisk-Users] Removing "-" (Dash) from Dialed Numbers
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. Help is always appreciated! :-) Thank you, Scott Miller -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20050923/39400ca0/attachment.htm
Ron Wellsted
2005-Sep-23 12:34 UTC
[Asterisk-Users] Removing "-" (Dash) from Dialed Numbers
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Scott Miller wrote:> 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. > > > > Help is always appreciated! J > > > > Thank you, > > Scott MillerHow about the Cut application (depreciated) <http://www.voip-info.org/tiki-index.php?page=Asterisk+cmd+cut> or the CUT function <http://www.voip-info.org/tiki-index.php?page=Asterisk+func+cut> depending on which version you are running? - -- Ron Wellsted http://www.wellsted.org.uk ron@wellsted.org.uk FWD:519961 N 52.567623, W 2.137621 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iQEVAwUBQzRYuUtP/KMNOfRbAQJOLAf/XkvLC/YvvfQDv4KgRiouXSUvjxSQwi5J C1HdKL5BNW1rsUnyxvqP5etQ3XyK0Xj3Vf4slqqXzI3TZzMITwQw9jQA2qroqagO 3DR5Dbao100IZhCq4MYEJIvmZYcd0PR5cd4s7acIwfwoA0OYeV9JMs7hQWMu/yOy PmGM2DQe21AT417uyIZ3rKWZfCkuAPL36q1p/rVfHpwVOzPj2PjjDB/gb6H+o/BK jiWhPTOpkDaKx2SeImF3T1vGjRJLEyVQRK63EmAUAzLnImqU011T0vQeeCVRTjND 3/sOwSVSKVH1t+bwZ5COvf3XHwWz1K6zitX67iAZQTN2gjZfzNNM5g==/vq+ -----END PGP SIGNATURE-----
Colin Anderson
2005-Sep-23 12:46 UTC
[Asterisk-Users] Removing "-" (Dash) from Dialed Numbers
Not very elegant, but: exten => 1,1,SetVar(MyNumber=780-555-1212) exten => 1,2,SetVar(AreaCode=${MyNumber:3:3}) exten => 1,3,SetVar(Prefix=${MyNumber:5:7}) exten => 1,4,SetVar(Suffix=${MyNumber:8:11}) exten => 1,5,Dial(ZAP/g0/1${AreaCode}${Prefix}${Suffix}) hth -----Original Message----- From: Scott Miller [mailto:scoscmil@imap.iu.edu] Sent: Friday, September 23, 2005 1:22 PM To: asterisk-users@lists.digium.com Subject: [Asterisk-Users] Removing "-" (Dash) from Dialed Numbers 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. Help is always appreciated! :-) Thank you, Scott Miller -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20050923/7b324e12/attachment.htm
Andreas Sikkema
2005-Sep-27 00:25 UTC
[Asterisk-Users] Removing "-" (Dash) from Dialed Numbers
asterisk-users-bounces@lists.digium.com wrote:>> 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. > 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 ########Depending on how many calls per second you want to perform, some dialplan magic might be cheaper than starting up a perl process. I'd write a diaplan macro for this. If the numbers are in a fixed format (4th character is a -, 7th character is a -, etc), then it's really simple. Something like this: exten => s,1,SetVar(strPart1 = ${myNumber:0:3} exten => s,2,SetVar(strPart2 = ${myNumber:4:3} exten => s,3,SetVar(strPart3 = ${myNumber:7:3} exten => s,4,SetVar(myNumber = $strPart1$strPart2$strPart3 But I'm using quite an old Asterisk, so current syntax might be a little different, but the Wiki suggests this still works. -- Andreas Sikkema bbned NV Van Vollenhovenstraat 3 3016 BE Rotterdam t: +31 (0)10 2245544 f: +31 (0)10 413 65 45