[Freeswitch-users] Lua script with arguments called from Dialplan

Petr Both both at antek.it
Wed May 23 08:06:50 UTC 2018


Hi,

Thank you very much for confirmation.

This morning I made again the tests with

<action application="lua" data="TestArg.lua 3000"/>

and then also with

<action application="lua" data="TestArg.lua ${destination_number}"/>

and using the same script like yesterday it works fine now. Probably I 
had the FS in some inconsistent state, destroyed by non-sense 
modifications in DIALPLAN xml configuration.

So using now in lua script the code

freeswitch.consoleLog("INFO", "INCOMING START CALL * to FreeSWITCH, 
arguments from DIALPLAN " ..argv[1].." "..#argv)

it works fine. Btw. I have found also another way how to get the 
destination number in Lua script which is

local CgNumb = tonumber(session:getVariable("destination_number"))

which is probably the equivalent of the same variable delivered from 
DIALPLAN.

So thank you very much again.

Regards
Petr B.

Dne 22.05.2018 v 18:37 Mario napsal(a):
> I agree it should work, I call Lua in incoming and outgoing dial plans 
> using the literal CALLIN and others and it works fine.
>  <action application="lua" data="TxCall.lua CALLIN”/>
> But I do not use a numeric literal. You should test with an alpha, if 
> that works then there is an issue with numbers that should be reported 
> in JIRA, then I would assign 3000 to a variable and pass that since I 
> know that also works.
> Mario G
>
>> On May 22, 2018, at 8:53 AM, Alexandr Popov 
>> <alexandr.popov at iqoption.com <mailto:alexandr.popov at iqoption.com>> wrote:
>>
>> it must work
>>
>> 2018-05-22 18:00 GMT+03:00 Petr Both <both at antek.it 
>> <mailto:both at antek.it>>:
>>
>>     Hi all,
>>
>>     I'm trying to call Lua script from the dialplan using the
>>     following section in etc/freeswitch/diaplan/default.xml
>>
>>        <extension name="New_Extension">
>>           <condition field="destination_number"
>>     expression="^(3[0-9][0-9][0-9])$">
>>            <action application="lua" data="TxCall.lua 3000"/>
>>           </condition>
>>         </extension>
>>
>>     I.e. the TxCall.lua is called with argument 3000 and should be
>>     available in lua script intself in argv[1] member of the argv
>>     field. However trying to use argv[1] the lua reports nil in this
>>     member of this field. argv[0] contains correctly name of the
>>     script but argv[1] seems to be empty. Seems like arguments are
>>     not delivered to lua script from dialplan.
>>
>>     I have also found the description if FS manual where such usage
>>     of dialplan is described but as I described above it doesn't work
>>     for me.
>>
>>     Location in manual is
>>     https://freeswitch.org/confluence/display/FREESWITCH/mod_lua
>>     <https://freeswitch.org/confluence/display/FREESWITCH/mod_lua>
>>     chapter "Sample Dialplan"
>>
>>     Is there any special trick to deliver arguments into the script
>>     from Dialplan?
>>
>>     Regards
>>     Petr B.
>>
>>
>>
>>     _________________________________________________________________________
>>     Professional FreeSWITCH Consulting Services:
>>     consulting at freeswitch.org <mailto:consulting at freeswitch.org>
>>     http://www.freeswitchsolutions.com
>>     <http://www.freeswitchsolutions.com/>
>>
>>     Official FreeSWITCH Sites
>>     http://www.freeswitch.org <http://www.freeswitch.org/>
>>     http://confluence.freeswitch.org <http://confluence.freeswitch.org/>
>>     http://www.cluecon.com <http://www.cluecon.com/>
>>
>>     FreeSWITCH-users mailing list
>>     FreeSWITCH-users at lists.freeswitch.org
>>     <mailto:FreeSWITCH-users at lists.freeswitch.org>
>>     http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>     <http://lists.freeswitch.org/mailman/listinfo/freeswitch-users>
>>     UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>>     <http://lists.freeswitch.org/mailman/options/freeswitch-users>
>>     http://www.freeswitch.org <http://www.freeswitch.org/>
>>
>>
>> _________________________________________________________________________
>> Professional FreeSWITCH Consulting Services:
>> consulting at freeswitch.org <mailto: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
>
>
>
> _________________________________________________________________________
> 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/20180523/33ef8ce5/attachment-0001.html>


More information about the FreeSWITCH-users mailing list