<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div style="RIGHT: auto"><SPAN style="RIGHT: auto">Thank you very much for your help! it now works.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <VAR id=yui-ie-cursor></VAR></SPAN><BR style="RIGHT: auto"></div>
<DIV style="FONT-FAMILY: times new roman, new york, times, serif; FONT-SIZE: 12pt">
<DIV style="FONT-FAMILY: times new roman, new york, times, serif; FONT-SIZE: 12pt">
<DIV style="RIGHT: auto" dir=ltr><FONT size=2 face=Arial>
<DIV style="BORDER-BOTTOM: #ccc 1px solid; BORDER-LEFT: #ccc 1px solid; PADDING-BOTTOM: 0px; LINE-HEIGHT: 0; MARGIN: 5px 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; HEIGHT: 0px; FONT-SIZE: 0px; BORDER-TOP: #ccc 1px solid; BORDER-RIGHT: #ccc 1px solid; PADDING-TOP: 0px" class=hr readonly="true" contenteditable="false"></DIV><B><SPAN style="FONT-WEIGHT: bold">From:</SPAN></B> Antonio &lt;asilva@wirelessmundi.com&gt;<BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> FreeSWITCH Users Help &lt;freeswitch-users@lists.freeswitch.org&gt; <BR><B><SPAN style="FONT-WEIGHT: bold">Sent:</SPAN></B> Tuesday, March 13, 2012 6:12 PM<BR><B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B> Re: [Freeswitch-users] Failed to pass arguments to lua script of FreeSwitch ('arg' and 'arg[i]' are nil values)<BR></FONT></DIV><WBR>
<DIV id=yiv1797394818>
<DIV>Hi,<WBR><WBR>Your&nbsp; missing an "V" in the arg name, "argv".<WBR><WBR>You can try do the following:<WBR><WBR>in diaplan:<WBR><WBR>&lt;extension name="call lua script" continue="true"&gt;<WBR>&lt;condition&gt;<WBR>&lt;action application="lua" data="yourcript.lua var1 var2"/&gt;<WBR>&lt;/condition&gt;<WBR>&lt;/extension&gt;<WBR><WBR><WBR>in the lua:<WBR><WBR>var1 = argv[1] or "default value to avoid errors"<WBR>var2 = argv[1] or "default value var2"<WBR><WBR>freeswitch.consoleLog("info", tostring(var1) .. "\n")<WBR>freeswitch.consoleLog("info", tostring(var2) .. "\n")<WBR><WBR><WBR>you can also call the lua script directly from the cli:<WBR><WBR>fs:&gt; luarun yourcript.lua var1 var2<WBR><WBR><WBR>Regards,<WBR>António<WBR><WBR><WBR><WBR>On Tue, 2012-03-13 at 02:46 -0700, king2kin wrote: <WBR>
<BLOCKQUOTE TYPE="CITE">Hi all, <BR>&nbsp;<BR>It's said we could access the arguments passed to lua script by variable 'arg[i]' where i &gt; 0.<BR>&nbsp;<BR>for example,&nbsp; { lua dummy.lua&nbsp; aa 100 }<BR>then, we will have as follows:<BR>arg[1] -&gt; aa<BR>arg[2] -&gt; 100<BR>&nbsp;<BR>However, I always get 'nil' values for 'arg[i]' or 'arg' while running the lua script.<BR>&nbsp;<BR>How can I pass and retrieve arguments or parameters to a lua script of FreeSwitch?<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;<BR>&nbsp; <PRE>_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
<A href="mailto:consulting@freeswitch.org" rel=nofollow target=_blank ymailto="mailto:consulting@freeswitch.org">consulting@freeswitch.org</A>
http://www.freeswitchsolutions.com

FreeSWITCH-powered IP PBX: The CudaTel Communication Server
http://www.cudatel.com

Official FreeSWITCH Sites
http://www.freeswitch.org
http://wiki.freeswitch.org
http://www.cluecon.com

FreeSWITCH-users mailing list
<A href="mailto:FreeSWITCH-users@lists.freeswitch.org" rel=nofollow target=_blank ymailto="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</A>
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:<A href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel=nofollow target=_blank>http://lists.freeswitch.org/mailman/options/freeswitch-users</A>
<A href="http://www.freeswitch.org/" rel=nofollow target=_blank>http://www.freeswitch.org</A>
</PRE></BLOCKQUOTE><WBR>
<TABLE cellSpacing=0 cellPadding=0 width="100%">
<TBODY>
<TR>
<TD><PRE>-- 

Un cordial saludo / Best regards, 

&nbsp;_________________________

António Silva

E-mail:<A href="mailto:asilva@wirelessmundi.com" rel=nofollow target=_blank ymailto="mailto:asilva@wirelessmundi.com">asilva@wirelessmundi.com</A>
</PRE></TD></TR></TBODY></TABLE></DIV></DIV><WBR>_________________________________________________________________________<WBR>Professional FreeSWITCH Consulting Services:<WBR><A href="mailto:consulting@freeswitch.org" ymailto="mailto:consulting@freeswitch.org">consulting@freeswitch.org</A><WBR><A href="http://www.freeswitchsolutions.com/" target=_blank>http://www.freeswitchsolutions.com</A><WBR><WBR>FreeSWITCH-powered IP PBX: The CudaTel Communication Server<WBR><A href="http://www.cudatel.com/" target=_blank>http://www.cudatel.com</A><WBR><WBR>Official FreeSWITCH Sites<WBR><A href="http://www.freeswitch.org/" target=_blank>http://www.freeswitch.org</A><WBR><A href="http://wiki.freeswitch.org/" target=_blank>http://wiki.freeswitch.org</A><WBR><A href="http://www.cluecon.com/" target=_blank>http://www.cluecon.com</A><WBR><WBR>FreeSWITCH-users mailing list<WBR><A href="mailto:FreeSWITCH-users@lists.freeswitch.org"
 ymailto="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</A><WBR><A href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target=_blank>http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</A><WBR>UNSUBSCRIBE:<A href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target=_blank>http://lists.freeswitch.org/mailman/options/freeswitch-users</A><WBR><A href="http://www.freeswitch.org/" target=_blank>http://www.freeswitch.org</A><WBR><WBR><WBR></DIV></DIV></div></body></html>