AGI script stripping leading '0'?

I’m using Lorne’s custom check whitelist code

exten => s,1,Noop(Entering user defined context [add-cid-to-whitelist] in extensions_custom.conf)
exten => s,n,set(name=${STRREPLACE(CALLERID(name),\,)})     ; remove commas from name before passing as agi arg
exten => s,n,AGI(lgaetz-cmadd.php,${CALLERID(number)},${name})
exten => s,n,Return

And I’ve noticed it seems to be stripping preceding '0’s sometimes? Any idea why?

Thank you!

PHP. If the item with the leading zero looks like a number and the code isn’t explicit about it, this happens.

I’ve tested and don’t have issues adding numbers with leading zeros. Depending on where you got the sample dialplan, you may see where I’ve normalized the phone number to 10 digits for consistency here in North America, in which case you will see the var referenced like this:


If you don’t want to do this, you would need to delete the :-10

1 Like

Thansk Lorne - we have 11 digit numbers here in the UK on the whole, but there are definitely exceptions as you’d expect for a telephone network as old as ours.

There’s NO mention of ${CALLERID(number):-10} in my extensions_custom.conf, so I’ll have to see if I can find anywhere else in the system where ${CALLERID(number):-10} is being set.
Really can’t think where, though! It’s interesting to note that with most numbers this isn’t happening, it SEEMS to be creeping in via the “add dialled CID” code rather than via the calls which pass the Turing test. They seem to be allowed to keep their 0s.

Happy to post the entire extension_custom if it would be thought to be useful.


cat /etc/asterisk/extensions_custom.conf | pastebin

I don’t have pastebin installed so I copied and pasted manually to here. Thank you


exten => s,n,AGI(lgaetz-cmadd.php,${OUTNUM:-10}) ; normalize numbers to 10 digits


Sorry Lorne!! I did this:

having taken you too literally earlier. Sorry!!

EDIT Oh I am sorry - what a waste of time. I can see it plain as day now. Sorry!!

It’s only a waste if you come back next week with the same question. Otherwise it’s one more step on the learning curve. Plus you might just save someone from posting the same question in the future.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.