Zarko Zivanovic
2010-Jul-28 12:04 UTC
[asterisk-users] Passing Variables From Dial Macro To Parent Ruby
Thanks to help from Jim Dickenson I managed to start a macro and get info about the channel that picked up the call from my ruby script. The only thing that I cant do so far, is capturing the ${CHANNEL} variable in the ruby script that started the macro. Is that variable accessible from the ruby script too or just from the macro? Here's a snippet from my ruby script: dial_params << "||M(testing)m(moh-0900-#{@moh_id})" if moh_available?() 1.times do r = $agi.exec('DIAL', dial_params) r = $agi.get_variable('DIALSTATUS') retry if r.message.include?('BUSY') end and further below: $loc = "testing" $my.query("UPDATE call_log SET local='#{$loc}', endtime = NOW() WHERE id = #{call_log_id}") Works fine, but as soon as I try: $loc = ${CHANNEL} or something like that - it breaks. Any idea how to pass that ${CHANNEL} to my ruby script and use it to update DB in that query? Thanks a bunch ! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20100728/f43774fd/attachment.htm
Philipp von Klitzing
2010-Jul-28 12:38 UTC
[asterisk-users] Passing Variables From Dial Macro To Parent Ruby
Hi! Three notes: * as others have already mentioned: personally I would not Dial() from within AGI using EXEC, but rather set extension and context and then let the dialplan handle the Dial, and therefore complete that AGI before the Dial; then possibly run another AGI after the call in the h extension (even if that might not scale so well it is usually just fine). * the second call leg is already gone when call control returns to your AGI, that is why you cannot read its variables. The only way is to use your M() Macro to store the value you are interested in, either by putting it into the CDR(userfield), or by using the SHARED() function (there is a backport for Asterisk 1.4) that can export the data to the originating channel. * you need to do a GET VARIABLE in your AGI, not sure if this works flawlessly with the CHANNEL variables though Philipp