[Freeswitch-users] Failed to pass arguments to lua script of FreeSwitch ('arg' and 'arg[i]' are nil values)

king2kin xing2kin at yahoo.com
Tue Mar 13 20:11:36 MSK 2012


Thank you very much for your help! it now works.      

From: Antonio <asilva at wirelessmundi.com>
To: FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org> 
Sent: Tuesday, March 13, 2012 6:12 PM
Subject: Re: [Freeswitch-users] Failed to pass arguments to lua script of FreeSwitch ('arg' and 'arg[i]' are nil values)

Hi,Your  missing an "V" in the arg name, "argv".You can try do the following:in diaplan:<extension name="call lua script" continue="true"><condition><action application="lua" data="yourcript.lua var1 var2"/></condition></extension>in the lua:var1 = argv[1] or "default value to avoid errors"var2 = argv[1] or "default value var2"freeswitch.consoleLog("info", tostring(var1) .. "\n")freeswitch.consoleLog("info", tostring(var2) .. "\n")you can also call the lua script directly from the cli:fs:> luarun yourcript.lua var1 var2Regards,AntónioOn Tue, 2012-03-13 at 02:46 -0700, king2kin wrote: 
Hi all, 
> 
>It's said we could access the arguments passed to lua script by variable 'arg[i]' where i > 0.
> 
>for example,  { lua dummy.lua  aa 100 }
>then, we will have as follows:
>arg[1] -> aa
>arg[2] -> 100
> 
>However, I always get 'nil' values for 'arg[i]' or 'arg' while running the lua script.
> 
>How can I pass and retrieve arguments or parameters to a lua script of FreeSwitch?
> 
> 
> 
> 
> 
> 
> 
>  
>_________________________________________________________________________
Professional FreeSWITCH Consulting Services: consulting at freeswitch.org http://www.freeswitchsolutions.com




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

FreeSWITCH-users mailing list FreeSWITCH-users at lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org 
-- 

Un cordial saludo / Best regards, 

 _________________________

António Silva

E-mail:asilva at wirelessmundi.com  _________________________________________________________________________Professional FreeSWITCH Consulting Services:consulting at freeswitch.orghttp://www.freeswitchsolutions.comFreeSWITCH-powered IP PBX: The CudaTel Communication ServerOfficial FreeSWITCH Siteshttp://www.freeswitch.orghttp://wiki.freeswitch.orghttp://www.cluecon.comFreeSWITCH-users mailing listFreeSWITCH-users at lists.freeswitch.orghttp://lists.freeswitch.org/mailman/listinfo/freeswitch-usersUNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-usershttp://www.freeswitch.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20120313/2a50bfcf/attachment.html 


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list