[asterisk-users] Properly Escaping Quotes and Commas

Cody Harris qbasicer at gmail.com
Thu Dec 22 13:02:43 CST 2011


I just tried to use replace, but I'm not sure I got the syntax right:

exten => s,n,Set(IMCID=${REPLACE("${CALLERID(all)}",",')})

complains

[Dec 22 14:01:29] ERROR[16755]: pbx.c:3528 ast_func_read2: Function  not
registered

Any suggestions?  Thanks!

On Thu, Dec 22, 2011 at 11:40 AM, Danny Nicholas <danny at debsinc.com> wrote:

> You could use the REPLACE function to zap the quotes and commas.****
>
> asterisk -rx "core show function REPLACE"****
>
> ** **
>
>   -= Info about function 'REPLACE' =-****
>
> ** **
>
> [Synopsis]****
>
> Replace a set of characters in a given string with another character.****
>
> ** **
>
> [Description]****
>
> Iterates through a string replacing all the <find-chars> with <replace-ch*
> ***
>
> ar>.  <replace-char> may be either empty or contain one character.  If
> empty,****
>
> all <find-chars> will be deleted from the output.****
>
> NOTE: The replacement only occurs in the output.  The original variable is
> ****
>
> not altered.****
>
> ** **
>
> [Syntax]****
>
> REPLACE(varname,find-chars[,replace-char])****
>
> ** **
>
> [Arguments]****
>
> Not available****
>
> ** **
>
> [See Also]****
>
> Not available****
>
> ** **
>
> *From:* asterisk-users-bounces at lists.digium.com [mailto:
> asterisk-users-bounces at lists.digium.com] *On Behalf Of *Cody Harris
> *Sent:* Thursday, December 22, 2011 10:35 AM
> *To:* asterisk-users at lists.digium.com
> *Subject:* [asterisk-users] Properly Escaping Quotes and Commas****
>
> ** **
>
> Hello all,****
>
> I have a setup where Asterisk sends a message to a few jabber users on
> each incoming call, like:****
>
> ** **
>
> exten => s,n,Macro(sendim,"Incoming call from ${CALLERID(all)}")****
>
> ** **
>
> The macro looks like this:****
>
> ** **
>
> [macro-sendimuser2]****
>
> exten => s,n,JabberSend(asterisk,user2 at gmail.com,${ARG1})****
>
> exten => s,n,JabberSend(asterisk,user2 at internal.jabber.server.tld,${ARG1})
> ****
>
> ** **
>
> [macro-sendim]****
>
> exten => s,1,Noop("Holder");****
>
> same  => n,Macro(sendimuser1,${ARG1})****
>
> same  => n,Macro(sendimuser2,${ARG1})****
>
> ** **
>
> The issue I'm having, is if the callerID contains a command, such as:
> Lastname, Firstname, ${CALLERID(all)} turns into "Lastname, Firstname"
> <number>.****
>
> ** **
>
> This seems to mess up the quoting, as the macro argument expands to be****
>
> "Incoming call from "Lastname, Firstname" <number>, and the ${ARG1} as the
> macro sees it is set to "Incoming call from "Lastname****
>
> ** **
>
> The comma ends up outside the double quotes and then it splits the macro
> arguments.****
>
> ** **
>
> What's the best way to do this right?****
>
> ** **
>
> ** **
>
> Thanks!!!****
>
> --
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
> New to Asterisk? Join us for a live introductory webinar every Thurs:
>               http://www.asterisk.org/hello
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>   http://lists.digium.com/mailman/listinfo/asterisk-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20111222/746e518c/attachment.htm>


More information about the asterisk-users mailing list