Failed to pass arguments to lua script of FreeSwitch ('arg' and 'arg[i]' are nil values)
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?
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 var2 Regards, António On 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@freeswitch.org 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 FreeSWITCH-users@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@wirelessmundi.com
Thank you very much for your help! it now works. From: Antonio <asilva@wirelessmundi.com> To: FreeSWITCH Users Help <freeswitch-users@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@freeswitch.org 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 FreeSWITCH-users@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@wirelessmundi.com _________________________________________________________________________Professional FreeSWITCH Consulting Services:consulting@freeswitch.orghttp://www.freeswitchsolutions.comFreeSWITCH-powered IP PBX: The CudaTel Communication Serverhttp://www.cudatel.comOfficial FreeSWITCH Siteshttp://www.freeswitch.orghttp://wiki.freeswitch.orghttp://www.cluecon.comFre... mailing listFreeSWITCH-users@lists.freeswitch.orghttp://lists.freeswitch.org/mailman/listinfo/freeswitch-usersUNSUBSCRIBE:htt...
participants (2)
-
Antonio
-
king2kin