Solved

Strip prefix

Posted on 2008-10-17
11
367 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
Comment Utility
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
Comment Utility
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
Comment Utility
rootforce, How to use IF/Then inside my a2billing context?I didn't find the right syntax by googeling it

Regards
0
 

Expert Comment

by:rootforce
Comment Utility
You would use

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

Sorry, the If Then was for example only.
0
 

Expert Comment

by:rootforce
Comment Utility
Or you might be looking to do this...
exten => _+X.,1,GotoIf($[${EXTEN:1} = 111] ? 21)
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Expert Comment

by:rootforce
Comment Utility
[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
Comment Utility
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
Comment Utility
Why not filter like I suggested?
0
 
LVL 9

Author Comment

by:michofreiha
Comment Utility
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
Comment Utility
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
Comment Utility
Very Good answer
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

So you think no one can listen in on your VOIP conversations, eh? Well... if you haven't setup Secure Real Time Transport (SRTP), your voice communications can be hacked into by just about anyone! First, let's talk about the intended audience for…
Hey there Heard about jingle, the add on for XMPP that enables point to point audio between two XMPP clients. No server config necessary. Actually quite a cool feature. However, how good is it if you can not use those voice capabilities to do a P…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now