Solved

Strip prefix

Posted on 2008-10-17
11
377 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 

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 learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need manual for NEC 92753A phone 5 157
Shared number solutions 1 64
Shoretel Edge Gateway 5 94
replacing 2811 to ISR 4331 2 44
The Zaptel people (www.zaptel.com) got kind of annoyed with the fact that they were getting bombarded with searches for the zaptel driver system for Asterisk (not to mention they own the trademark on zaptel). So, they kindly requested that Digium ch…
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…

749 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