Solved

Strip prefix

Posted on 2008-10-17
11
382 Views
Last Modified: 2013-11-12
Dear All,

i have the following context defines in etensions.conf:


[a2billing]
exten => _X.,1,Gotoif($[${EXTEN} = 111] ? 21)
exten => _X.,2,DeadAGI,a2billing.php
exten => _X.,3,Wait,2
exten => _X.,4,Hangup
exten => _X.,21,Playback(AR_GetGiveToID)
exten => _X.,22,Wait(2)
exten => _X.,23,Record(/tmp/asterisk-recording:ulaw,,5)
exten => _X.,24,Wait(2)
exten => _X.,25,Playback(/tmp/asterisk-recording)
exten => _X.,26,Wait(2)
exten => _X.,27,Hangup

I just need to remove the '+' sign from the dialed number just in case any user put the '+' as Internationa prefix...Is that possible?How to do that?

Regards
0
Comment
Question by:michofreiha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 3
11 Comments
 

Expert Comment

by:rootforce
ID: 22746319
The key here is asterisk variable substrings.
i.e.
If ${EXTEN} = +19729991234
Then
${EXTEN:1} = 19729991234
${EXTEN:-1} = 4
${EXTEN:0:3} = +197

Reference: http://www.voip-info.org/wiki-Asterisk+variables
0
 
LVL 4

Expert Comment

by:palner
ID: 22746914
Here's a different approach that I love using for caller id. This should apply to you as well...

Set(VARIABLE=${FILTER(0123456789,${EXTEN})})

So if you wanted the variable to be let's say NUMDIALED

you would do this:

Set(NUMDIALED=${FILTER(0123456789,${EXTEN})})

And then within future scripts and the dialplan, refer to ${NUMDIALED} instead of ${EXTEN}

0
 
LVL 9

Author Comment

by:michofreiha
ID: 22755821
rootforce, How to use IF/Then inside my a2billing context?I didn't find the right syntax by googeling it

Regards
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 

Expert Comment

by:rootforce
ID: 22757030
You would use

exten => _X.,1,Gotoif($[${EXTEN:1} = 111] ? 21)

Sorry, the If Then was for example only.
0
 

Expert Comment

by:rootforce
ID: 22757058
Or you might be looking to do this...
exten => _+X.,1,GotoIf($[${EXTEN:1} = 111] ? 21)
0
 

Expert Comment

by:rootforce
ID: 22757078
[a2billing]

exten => _+X.,1,Gotoif($[${EXTEN:1} = 111] ? 21)
exten => _+X.,2,DeadAGI,a2billing.php
exten => _+X.,3,Wait,2
exten => _+X.,4,Hangup
exten => _+X.,21,Playback(AR_GetGiveToID)
exten => _+X.,22,Wait(2)
exten => _+X.,23,Record(/tmp/asterisk-recording:ulaw,,5)
exten => _+X.,24,Wait(2)
exten => _+X.,25,Playback(/tmp/asterisk-recording)
exten => _+X.,26,Wait(2)
exten => _+X.,27,Hangup

exten => _X.,1,Gotoif($[${EXTEN} = 111] ? 21)
exten => _X.,2,DeadAGI,a2billing.php
exten => _X.,3,Wait,2
exten => _X.,4,Hangup
exten => _X.,21,Playback(AR_GetGiveToID)
exten => _X.,22,Wait(2)
exten => _X.,23,Record(/tmp/asterisk-recording:ulaw,,5)
exten => _X.,24,Wait(2)
exten => _X.,25,Playback(/tmp/asterisk-recording)
exten => _X.,26,Wait(2)
exten => _X.,27,Hangup
0
 
LVL 9

Author Comment

by:michofreiha
ID: 22758334
Kindly note that + will never work with Gotoif because it's considering it as the + of the math...DO you have any other method that could work?

Regards
0
 
LVL 4

Expert Comment

by:palner
ID: 22758353
Why not filter like I suggested?
0
 
LVL 9

Author Comment

by:michofreiha
ID: 22758413
Dear Palner,

Can you explain more about how to use the filter function that eliminate the + sign?

Regards
0
 
LVL 4

Accepted Solution

by:
palner earned 500 total points
ID: 22758525
Set(NUMDIALED=${FILTER(0123456789,${EXTEN})})

You could use that or just filter the exten...

like....

exten => _+X.,1,Gotoif($[${FILTER(0123456789,${EXTEN})} = 111] ? 21)
exten => _+X.,2,DeadAGI,a2billing.php
exten => _+X.,3,Wait,2
exten => _+X.,4,Hangup
exten => _+X.,21,Playback(AR_GetGiveToID)
exten => _+X.,22,Wait(2)
exten => _+X.,23,Record(/tmp/asterisk-recording:ulaw,,5)
exten => _+X.,24,Wait(2)
exten => _+X.,25,Playback(/tmp/asterisk-recording)
exten => _+X.,26,Wait(2)
exten => _+X.,27,Hangup
0
 
LVL 9

Author Closing Comment

by:michofreiha
ID: 31507164
Very Good answer
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How To Create Custom / Distinctive Ring Tones on Polycom Phones Purpose and Overview When creating a custom ring tone, you have simple aspirations: to make your phone cooler than everyone else's. Perhaps you need a louder ringer. Perhaps you w…
In my office we had 10 Cisco 7940G IP phones that were useless as they were showing PROTOCOL APPLICATION INVALID when started. I searched through Google and worked for a week continuously on those phones, and finally got them working. This is a di…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question