Jonas Kellens
2015-Mar-16 13:00 UTC
[asterisk-users] Use dialplan variables from MySQL database and replace with value
Hello i have the following field (text string) in a MySQL database : "${KNUMMER} ${phone_number_to} ${phone_number_from} ${CHANNEL:4}" I read this string form the database and want to have the dialplan variables to be replaced with the correct content. How can I do this ? Currently this is not working. The variable ${PARAMS} contains the exact string of the database field : my dialplan : exten => s,n,MYSQL(Connect connid localhost dbuser dbpass MyTable) exten => s,n,MYSQL(Query resultid ${connid} SELECT script_url, script_params FROM my_tbl WHERE ID="${myID}") exten => s,n,MYSQL(Fetch fetchid ${resultid} scriptURL PARAMS) exten => s,n,NoOp(scriptURL = ${scriptURL} PARAMS = ${PARAMS}) becomes : -- Executing [s at sub-details:4] MYSQL("SIP/SipT01-00000012", "Connect connid localhost dbuser dbpass MyTable") in new stack -- Executing [s at sub-details:5] MYSQL("SIP/SipT01-00000012", "Query resultid 1 SELECT script_url, script_params FROM my_tbl WHERE ID="2"") in new stack -- Executing [s at sub-details:6] MYSQL("SIP/SipT01-00000012", "Fetch fetchid 2 scriptURL PARAMS") in new stack -- Executing [s at sub-details:7] NoOp("SIP/SipT01-00000012", "scriptURL = call_end.php PARAMS = ${KNUMMER} ${phone_number_to} ${phone_number_from} ${CHANNEL:4}") in new stack If the variable ${PARAMS} contains other variables " ${KNUMMER} ${phone_number_to} ${phone_number_from} ${CHANNEL:4} ", how can I use the values of these variables in my dialplan ?? I want to use "${KNUMMER} ${phone_number_to} ${phone_number_from} ${CHANNEL:4} " as input to my script inside my dialplan : -- Executing [h at pbx-routing:43] System("SIP/SipT01-00000012", "/usr/bin/php /var/lib/asterisk/agi-bin/call_end.php ${KNUMMER} ${phone_number_to} ${phone_number_from} ${CHANNEL:4}") in new stack But in stead of having ${KNUMMER} I want to have "112233", and in stead of having ${phone_number_to} I want to have "31023456789" and so on... Is this possible ?? Kind regards, Jonas. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20150316/f467291a/attachment.html>
Joshua Colp
2015-Mar-18 21:21 UTC
[asterisk-users] Use dialplan variables from MySQL database and replace with value
Jonas Kellens wrote:> Hello > > > i have the following field (text string) in a MySQL database : > "${KNUMMER} ${phone_number_to} ${phone_number_from} ${CHANNEL:4}" > > I read this string form the database and want to have the dialplan > variables to be replaced with the correct content.Sounds like you need the EVAL dialplan function[1]. https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+Function_EVAL Cheers, -- Joshua Colp Digium, Inc. | Senior Software Developer 445 Jan Davis Drive NW - Huntsville, AL 35806 - US Check us out at: www.digium.com & www.asterisk.org