Solved

Strip prefix

Posted on 2008-10-17
11
372 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
  • 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

There are no good configuration guides for HP-H3C router to LYNC on the web. :( Big statement, but we havent been able to find one yet. We did find the following document useful, but the information was not enough to use H3C router for use as a L…
If your business is like most, chances are you still need to maintain a fax infrastructure for your staff. It’s hard to believe that a communication technology that was thriving in the mid-80s could still be an essential part of your team’s modern I…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

770 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