[Freeswitch-users] Need help with lua called from dial plan - How to delimit arguments?

Jyoti Prakash jyoti_prakash at outlook.com
Mon Jun 1 14:01:24 MSD 2015


why not access it as global variable like
session:getVariable("caller_id_name"); 
and pass it to some variable or you can take help from following snippet of code from 
 function randomize()	api = freeswitch.API();	seed = tonumber(api:execute("global_getvar", "randomseed"));	if seed == 12345678 or seed == "" or seed == nil then		seed = os.time();	end	math.randomseed(seed);	seed = math.random(1,999999)	api:execute("global_setvar", "randomseed=" .. seed)end
 I have taken it from https://wiki.freeswitch.org/wiki/Fakecall_responder

> Date: Sun, 31 May 2015 00:41:06 +0200
> From: dragic.dusan at gmail.com
> To: freeswitch-users at lists.freeswitch.org
> Subject: Re: [Freeswitch-users] Need help with lua called from dial plan - How to delimit arguments?
> 
> Use single quotes (but Giovanni's suggestion is the way to go).
> 
> On 30 May 2015 at 22:21, Jim Lynch <jim at k4gvo.com> wrote:
> > I have a line in my dialplan that looks like this:
> >      <action application="lua" data="cid.lua  ${caller_id_name}
> > ${caller_id_number}" />
> >
> > However when the program is executed and the caller_id_name has a space
> > in it, the number gets lost.
> > I can't figure out a way to add delimiters that get passed to the
> > shell.  None of these work:
> >
> >      <action application="lua" data="cid.lua \"${caller_id_name}\"
> > \"${caller_id_number}\"" />
> > or
> >      <action application="lua" data="cid.lua ''${caller_id_name}''
> > ''${caller_id_number}''" />
> > or
> >      <action application="lua" data="cid.lua \"\"${caller_id_name}\"\"
> > \"\"${caller_id_number}\"\"" />
> >
> > None of those work.  The quotes are all stripped off when running this test
> >
> > lua file:
> > tmp_file = "/tmp/cidtest.txt";
> > local file = assert(io.open(tmp_file, "a"));
> > local m_name=argv[1];
> > local m_number=argv[2];
> > file:write("j cid is ",m_name," number is ",m_number,"\n");
> >
> > Any suggestions?
> >
> > Thanks,
> > Jim.
> >
> > _________________________________________________________________________
> > Professional FreeSWITCH Consulting Services:
> > consulting at freeswitch.org
> > http://www.freeswitchsolutions.com
> >
> > Official FreeSWITCH Sites
> > http://www.freeswitch.org
> > http://confluence.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
> 
> 
> 
> -- 
> Dušan Dragić
> 
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services: 
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
> 
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.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
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20150601/7d89906d/attachment.html 


Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list