Solved

Strip prefix

Posted on 2008-10-17
11
375 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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The point of this post is to give you a copy/paste installation solution to setting up Asterisk 1.6 on Ubuntu 9.04 (or similar) server. # Setup the system apt-get install subversion apt-get install make apt-get install linux-source kernel-p…
Article by: user_n
How Sip Phone (User Agent) works and communicates with sip servers 1.  There is a sip server and a sip registrar.  The sip server and sip registrar can be one server or two different servers. The sip registrar is the server on which it is record…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

839 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