<div dir="ltr"><div>I have not read the script, etc, only first lines of your mail<br></div><div><br></div><div>I'd like to point you that you can use "luarun" that will execute script in nits own thread, no blocking, no waitin for result. Is probably what you want...</div><div><br></div><div>-giovanni</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 19, 2020 at 11:30 PM Wilmar Perez via FreeSWITCH-users <<a href="mailto:freeswitch-users@lists.freeswitch.org">freeswitch-users@lists.freeswitch.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br><br><br>---------- Forwarded message ----------<br>From: Wilmar Perez <<a href="mailto:ewdpb@yahoo.com" target="_blank">ewdpb@yahoo.com</a>><br>To: "<a href="mailto:freeswitch-users@lists.freeswitch.org" target="_blank">freeswitch-users@lists.freeswitch.org</a>" <<a href="mailto:freeswitch-users@lists.freeswitch.org" target="_blank">freeswitch-users@lists.freeswitch.org</a>><br>Cc: <br>Bcc: <br>Date: Wed, 18 Mar 2020 12:31:57 +0000 (UTC)<br>Subject: Using bgapi<br><div><div style="font-family:Helvetica Neue,Helvetica,Arial,sans-serif;font-size:10px"><div dir="ltr"><div><div><br><span style="font-family:Arial,Helvetica,sans-serif;font-size:small">Hi all,</span><br></div><div><div style="direction:ltr;margin:8px 0px 0px;padding:0px"><div 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/" style="color:rgb(17,85,204)" rel="nofollow" target="_blank">http://myapi.com</a>'<br>session:execute('curl', url); <br></div><div><br></div><div id="gmail-m_-4821955179515916259ydpf87adb5enhancr_card_5505943025" style="max-width:400px;font-family:"Helvetica Neue","Segoe UI",Helvetica,Arial,sans-serif"><a href="http://myapi.com/" style="text-decoration:none;color:rgb(0,0,0)" rel="nofollow" target="_blank"><table style="max-width:400px" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td width="400"><table style="max-width:400px;border-width:1px;border-style:solid;border-color:rgb(224,228,233);border-radius:2px" width="100%" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td><table style="background:rgb(255,255,255) none repeat scroll 0% 0%;width:100%;max-width:400px;border-radius:0px 0px 2px 2px;border-top:1px solid rgb(224,228,233)" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td style="background-color:rgb(255,255,255);padding:16px 0px 16px 12px;vertical-align:top;border-radius:0px 0px 0px 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:0px 0px 2px"><h2 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 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></div><div><br style="color:rgb(34,34,34)"></div></div></div></div></div></div><br></div></div></div><br><br><br>---------- Forwarded message ----------<br>From: Wilmar Perez via FreeSWITCH-users <<a href="mailto:freeswitch-users@lists.freeswitch.org" target="_blank">freeswitch-users@lists.freeswitch.org</a>><br>To: "<a href="mailto:freeswitch-users@lists.freeswitch.org" target="_blank">freeswitch-users@lists.freeswitch.org</a>" <<a href="mailto:freeswitch-users@lists.freeswitch.org" target="_blank">freeswitch-users@lists.freeswitch.org</a>><br>Cc: <br>Bcc: <br>Date: Thu, 19 Mar 2020 15:30:29 -0700 (PDT)<br>Subject: [Freeswitch-users] Using bgapi<br>_________________________________________________________________________<br>
<br>
The FreeSWITCH project is sponsored by SignalWire <a href="https://signalwire.com" rel="noreferrer" target="_blank">https://signalwire.com</a><br>
Enhance your FreeSWITCH install with disruptive priced SMS and PSTN services.<br>
Build your next product on our scalable cloud platform.<br>
<br>
Join our online community to chat in real time <a href="https://signalwire.community" rel="noreferrer" target="_blank">https://signalwire.community</a><br>
<br>
Professional FreeSWITCH Services<br>
<a href="mailto:sales@freeswitch.com" target="_blank">sales@freeswitch.com</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="https://freeswitch.com/oss" rel="noreferrer" target="_blank">https://freeswitch.com/oss</a><br>
<a href="https://freeswitch.org/confluence" rel="noreferrer" target="_blank">https://freeswitch.org/confluence</a><br>
<a href="https://cluecon.com" rel="noreferrer" target="_blank">https://cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a></blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature">Sincerely,<br><br>Giovanni Maruzzelli<br>OpenTelecom.IT<br>cell: +39 347 266 56 18<br><br></div>