Sponsor: VoiceMeUp - Corporate & Wholesale VoIP Services

VoIP Mailing List Archives
Mailing list archives for the VoIP community
 SearchSearch 

[asterisk-users] Use dialplan variables from MySQL database and replace with value


 
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> Asterisk Users
View previous topic :: View next topic  
Author Message
jonas.kellens at telen...
Guest





PostPosted: Mon Mar 16, 2015 8:01 am    Post subject: [asterisk-users] Use dialplan variables from MySQL database Reply with quote

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@sub-details:4] MYSQL("SIP/SipT01-00000012", "Connect connid localhost dbuser dbpass MyTable") in new stack
-- Executing [s@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@sub-details:6] MYSQL("SIP/SipT01-00000012", "Fetch fetchid 2 scriptURL PARAMS") in new stack
-- Executing [s@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@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.
Back to top
jcolp at digium.com
Guest





PostPosted: Wed Mar 18, 2015 4:21 pm    Post subject: [asterisk-users] Use dialplan variables from MySQL database Reply with quote

Jonas Kellens wrote:
Quote:
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

--
_____________________________________________________________________
-- 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
Back to top
Display posts from previous:   
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> Asterisk Users All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

VoiceMeUp - Corporate & Wholesale VoIP Services