<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"><head><!--[if gte mso 9]><xml><o:OfficeDocumentSettings><o:AllowPNG/><o:PixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml><![endif]--></head><body><div class="yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:10px;"><div dir="ltr" data-setdir="false"><div><div><br><span style="font-family: Arial, Helvetica, sans-serif; font-size: small;">Hi all,</span><br></div><div><div class="ydp2d7fba3cii ydp2d7fba3cgt" style="direction: ltr; margin: 8px 0px 0px; padding: 0px; position: relative;"><div class="ydp2d7fba3ca3s ydp2d7fba3caXjCH" style="font-stretch: normal; font-size: small; line-height: 1.5; font-family: Arial, Helvetica, sans-serif;"><div dir="ltr"><div><br></div><div>I am trying to wrap my head around the use of bgapi. What I am tryin gto is to call a lua script that executes a curl command. While curl does its thing I want to do something else (e.g. playing back some music on hold to the caller). I am trying to do this in pure LUA (no ESL - the only reason is that I did not know ESL existed at all when I started this project and now it is too late to go back).</div><div><br></div><div>So, I've been texting with the following scrip which simply executes an external script which is using mod curl. I woud expect some session variables to be set but it does not seem to be the case. I use a for loop just to check every few seconds the existence of the session variable.</div><div><br></div><div><b>My main script</b>:</div><div>-----------------------------------------------------------------------------------------------------------------------</div><div>----------------------------------------------------------------------------------------------------------------------- <br></div><div>session:answer();</div>api = freeswitch.API();<br><br>if(session:ready())then<br> reply = api:executeString('bgapi \'my_curl.lua\'');<br>end<br><br>for i=1, 30 do<br> if(session:getVariable('curl_response_code') == nil)then<br> freeswitch.consoleLog('Notice', 'Nothing to see yet')<br> session:execute('sleep', 500)<br> else<br> console_log('The data is' .. session:getVariable('curl_response_data'))<br> end<br> i = i + 1;<br>end<br><br>session:hangup();<div><div>-----------------------------------------------------------------------------------------------------------------------</div><div>----------------------------------------------------------------------------------------------------------------------- </div></div><div><br></div><div><div><b>My_curl.lua</b>:</div><div>-----------------------------------------------------------------------------------------------------------------------</div><div>----------------------------------------------------------------------------------------------------------------------- </div></div><div>local url = '<a href="http://myapi.com/" data-saferedirecturl="https://www.google.com/url?q=http://myapi.com&source=gmail&ust=1584621075256000&usg=AFQjCNGgJ5lxStEYuWoBtrAbaJthEMoSIA" style="color: rgb(17, 85, 204);" rel="nofollow" target="_blank" class="enhancr_card_5505943025">http://myapi.com</a>'<br>session:execute('curl', url); <br></div><div><br></div><div id="ydpf87adb5enhancr_card_5505943025" class="ydpf87adb5yahoo-link-enhancr-card ydpf87adb5yahoo-link-enhancr-not-allow-cover ydpf87adb5ymail-preserve-class ydpf87adb5ymail-preserve-style" style="max-width:400px;font-family:"Helvetica Neue", "Segoe UI", Helvetica, Arial, sans-serif" data-url="http://myapi.com/" data-type="YENHANCER" data-size="MEDIUM" contenteditable="false"><a href="http://myapi.com/" style="text-decoration:none !important;color:#000 !important" class="ydpf87adb5yahoo-enhancr-cardlink" rel="nofollow" target="_blank"><table border="0" class="ydpf87adb5card-wrapper ydpf87adb5yahoo-ignore-table" cellpadding="0" cellspacing="0" style="max-width:400px"><tbody><tr><td width="400"><table border="0" class="ydpf87adb5card ydpf87adb5yahoo-ignore-table" cellpadding="0" cellspacing="0" width="100%" style="max-width:400px;border-width:1px;border-style:solid;border-color:rgb(224, 228, 233);border-radius:2px"><tbody><tr><td><table border="0" class="ydpf87adb5card-info ydpf87adb5yahoo-ignore-table" cellpadding="0" cellspacing="0" style="background:#fff;position:relative;z-index:2;width:100%;max-width:400px;border-radius:0 0 2px 2px;border-top:1px solid rgb(224, 228, 233)"><tbody><tr><td style="background-color:#ffffff;padding:16px 0 16px 12px;vertical-align:top;border-radius:0 0 0 2px"></td><td style="vertical-align:middle;padding:12px 24px 16px 12px;width:99%;font-family:"Helvetica Neue", "Segoe UI", Helvetica, Arial, sans-serif;border-radius:0 0 2px 0"><h2 class="ydpf87adb5card-title" style="font-size: 14px; line-height: 19px; margin: 0px 0px 6px; font-family: "Helvetica Neue", "Segoe UI", Helvetica, Arial, sans-serif; color: rgb(38, 40, 42); max-width: 314px;">ADSCHEAPER.COM - Best online advertising, Monetize domains & intellectua...</h2><p class="ydpf87adb5card-description" style="font-size: 12px; line-height: 16px; margin: 0px; color: rgb(151, 155, 167);">AdsCheaper.com - cost effective advertising Monetize domains!</p></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></a></div><div><br></div><div><br></div><div><div>-----------------------------------------------------------------------------------------------------------------------</div><div>----------------------------------------------------------------------------------------------------------------------- </div></div><div><br></div><div>In the logs I can see something happening:</div><div><br></div><div>+OK Job-UUID: fbb932aa-d58b-4e9f-b658-c542eff0640d<br></div><div><br></div><div>But nothing else happens. My main script simply goes through the for look until the end and session variable curl_response_code never gets set.</div><div><br></div><div>Clearly I am probably misunderstanding how this whole thing works. Any hint or guid would be very helpful.</div><div><br></div><div>Thanks!</div><div class="ydp2d7fba3cyj6qo"></div><div class="ydp2d7fba3cadL"><br style="color: rgb(34, 34, 34);"></div></div></div></div></div></div><br></div></div></body></html>