Lua script not working in Freeswitch
Hello, I have a script that connects to a mysql db. The script works perfect when I type "lua <scriptname>", but when I have Freeswitch all the script I get the following error message. I have changed my script to now call a python script to read the database and I am experiencing the same result. If I call the script from the command line it works but Freeswitch throws this error. Please help, Thanks, 2014-01-03 18:52:28.381720 [ERR] mod_lua.cpp:199 /usr/local/freeswitch/scripts/testCallerID.lua:31: attempt to concatenate global 'pythonResult' (a userdata value) stack traceback: /usr/local/freeswitch/scripts/testCallerID.lua:31: in main chunk
Are you using .. in your script somewhere? There may be some work (like converting to string) that happens on the command line, but won't in dialplan use. Can we see line 31 of your script? On Friday, January 3, 2014, Joli Martinez wrote:
Hello,
I have a script that connects to a mysql db. The script works perfect when I type "lua <scriptname>", but when I have Freeswitch all the script I get the following error message. I have changed my script to now call a python script to read the database and I am experiencing the same result. If I call the script from the command line it works but Freeswitch throws this error.
Please help,
Thanks,
2014-01-03 18:52:28.381720 [ERR] mod_lua.cpp:199 /usr/local/freeswitch/scripts/testCallerID.lua:31: attempt to concatenate global 'pythonResult' (a userdata value) stack traceback: /usr/local/freeswitch/scripts/testCallerID.lua:31: in main chunk
attached is from 23-31. All the python script does is connects to the mysql db and returns a string back. I had to do it this way because the luasql was having the same issue. Script works when called via commandline, but when called in FS it fails. pythonResult = assert (io.popen ('/usr/bin/python python2lua.py ' ..callerID)) freeswitch.consoleLog("INFO","--------------------------------------------------\n"); freeswitch.consoleLog("INFO", "got here OK \n"); freeswitch.consoleLog("INFO","---------------------------------------------------\n"); freeswitch.consoleLog("INFO", '|'..pythonResult.. "-----\n"); On Jan 3, 2014, at 10:07 PM, Erik M. Devane - Comms Guy <emdevane@gmail.com> wrote:
Are you using .. in your script somewhere?
There may be some work (like converting to string) that happens on the command line, but won't in dialplan use.
Can we see line 31 of your script?
On Friday, January 3, 2014, Joli Martinez wrote: Hello,
I have a script that connects to a mysql db. The script works perfect when I type "lua <scriptname>", but when I have Freeswitch all the script I get the following error message. I have changed my script to now call a python script to read the database and I am experiencing the same result. If I call the script from the command line it works but Freeswitch throws this error.
Please help,
Thanks,
2014-01-03 18:52:28.381720 [ERR] mod_lua.cpp:199 /usr/local/freeswitch/scripts/testCallerID.lua:31: attempt to concatenate global 'pythonResult' (a userdata value) stack traceback: /usr/local/freeswitch/scripts/testCallerID.lua:31: in main chunk
_________________________________________________________________________ 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
In FreeSWITCH you're better off using https://wiki.freeswitch.org/wiki/Lua_freeswitch_dbh than luasql - I've seen reports on the ML of stability problems with the latter On 4 January 2014 03:43, Joli Martinez <mrjoli021@gmail.com> wrote:
attached is from 23-31. All the python script does is connects to the mysql db and returns a string back. I had to do it this way because the luasql was having the same issue. Script works when called via commandline, but when called in FS it fails.
pythonResult = assert (io.popen ('/usr/bin/python python2lua.py '..callerID))
freeswitch.consoleLog("INFO", "--------------------------------------------------\n"); freeswitch.consoleLog("INFO", "got here OK \n"); freeswitch.consoleLog("INFO", "---------------------------------------------------\n");
freeswitch.consoleLog("INFO", '|'..pythonResult.. "-----\n"); On Jan 3, 2014, at 10:07 PM, Erik M. Devane - Comms Guy < emdevane@gmail.com> wrote:
Are you using .. in your script somewhere?
There may be some work (like converting to string) that happens on the command line, but won't in dialplan use.
Can we see line 31 of your script?
On Friday, January 3, 2014, Joli Martinez wrote:
Hello,
I have a script that connects to a mysql db. The script works perfect when I type "lua <scriptname>", but when I have Freeswitch all the script I get the following error message. I have changed my script to now call a python script to read the database and I am experiencing the same result. If I call the script from the command line it works but Freeswitch throws this error.
Please help,
Thanks,
2014-01-03 18:52:28.381720 [ERR] mod_lua.cpp:199 /usr/local/freeswitch/scripts/testCallerID.lua:31: attempt to concatenate global 'pythonResult' (a userdata value) stack traceback: /usr/local/freeswitch/scripts/testCallerID.lua:31: in main chunk
_________________________________________________________________________ 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
_________________________________________________________________________ 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
Do you get a more clear error if you use : freeswitch.consoleLog("INFO", pythonResult); (Wondering if you're hitting a character limit or it doesn't like mixing quote types). Or does: freeswitch.consoleLog("INFO", '|'..tostring(pythonResult).. "-----\n"); Work better? On Friday, January 3, 2014, Joli Martinez wrote:
attached is from 23-31. All the python script does is connects to the mysql db and returns a string back. I had to do it this way because the luasql was having the same issue. Script works when called via commandline, but when called in FS it fails.
pythonResult = assert (io.popen ('/usr/bin/python python2lua.py '..callerID))
freeswitch.consoleLog("INFO", "--------------------------------------------------\n"); freeswitch.consoleLog("INFO", "got here OK \n"); freeswitch.consoleLog("INFO", "---------------------------------------------------\n");
freeswitch.consoleLog("INFO", '|'..pythonResult.. "-----\n"); On Jan 3, 2014, at 10:07 PM, Erik M. Devane - Comms Guy < emdevane@gmail.com <javascript:_e({}, 'cvml', 'emdevane@gmail.com');>> wrote:
Are you using .. in your script somewhere?
There may be some work (like converting to string) that happens on the command line, but won't in dialplan use.
Can we see line 31 of your script?
On Friday, January 3, 2014, Joli Martinez wrote:
Hello,
I have a script that connects to a mysql db. The script works perfect when I type "lua <scriptname>", but when I have Freeswitch all the script I get the following error message. I have changed my script to now call a python script to read the database and I am experiencing the same result. If I call the script from the command line it works but Freeswitch throws this error.
Please help,
Thanks,
2014-01-03 18:52:28.381720 [ERR] mod_lua.cpp:199 /usr/local/freeswitch/scripts/testCallerID.lua:31: attempt to concatenate global 'pythonResult' (a userdata value) stack traceback: /usr/local/freeswitch/scripts/testCallerID.lua:31: in main chunk
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <javascript:_e({}, 'cvml', '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 <javascript:_e({}, 'cvml', '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
I wonder if assert actually returns a value. Perhaps you need to do the assert on pythonResult after it has been assigned to the return value of io.popen. On 5 January 2014 02:05, Erik M. Devane - Comms Guy <emdevane@gmail.com>wrote:
Do you get a more clear error if you use :
freeswitch.consoleLog("INFO", pythonResult);
(Wondering if you're hitting a character limit or it doesn't like mixing quote types).
Or does:
freeswitch.consoleLog("INFO", '|'..tostring(pythonResult).. "-----\n");
Work better?
On Friday, January 3, 2014, Joli Martinez wrote:
attached is from 23-31. All the python script does is connects to the mysql db and returns a string back. I had to do it this way because the luasql was having the same issue. Script works when called via commandline, but when called in FS it fails.
pythonResult = assert (io.popen ('/usr/bin/python python2lua.py '..callerID))
freeswitch.consoleLog("INFO", "--------------------------------------------------\n"); freeswitch.consoleLog("INFO", "got here OK \n"); freeswitch.consoleLog("INFO", "---------------------------------------------------\n");
freeswitch.consoleLog("INFO", '|'..pythonResult.. "-----\n"); On Jan 3, 2014, at 10:07 PM, Erik M. Devane - Comms Guy < emdevane@gmail.com> wrote:
Are you using .. in your script somewhere?
There may be some work (like converting to string) that happens on the command line, but won't in dialplan use.
Can we see line 31 of your script?
On Friday, January 3, 2014, Joli Martinez wrote:
Hello,
I have a script that connects to a mysql db. The script works perfect when I type "lua <scriptname>", but when I have Freeswitch all the script I get the following error message. I have changed my script to now call a python script to read the database and I am experiencing the same result. If I call the script from the command line it works but Freeswitch throws this error.
Please help,
Thanks,
2014-01-03 18:52:28.381720 [ERR] mod_lua.cpp:199 /usr/local/freeswitch/scripts/testCallerID.lua:31: attempt to concatenate global 'pythonResult' (a userdata value) stack traceback: /usr/local/freeswitch/scripts/testCallerID.lua:31: in main chunk
_________________________________________________________________________ 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
_________________________________________________________________________ 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
Hi Joli, is that FS current master or 1.2? In master is 5.2 lua included, in 1.2 is 5.1 Version. You could test your lua script with the full-path to the python script. Maybe the current working directory of lua is diffrent. pythonResult = assert (io.popen ('/usr/bin/python */my/full/path/*python2lua.py ' ..callerID)) 2014/1/4 Joli Martinez <mrjoli021@gmail.com>
Hello,
I have a script that connects to a mysql db. The script works perfect when I type "lua <scriptname>", but when I have Freeswitch all the script I get the following error message. I have changed my script to now call a python script to read the database and I am experiencing the same result. If I call the script from the command line it works but Freeswitch throws this error.
Please help,
Thanks,
2014-01-03 18:52:28.381720 [ERR] mod_lua.cpp:199 /usr/local/freeswitch/scripts/testCallerID.lua:31: attempt to concatenate global 'pythonResult' (a userdata value) stack traceback: /usr/local/freeswitch/scripts/testCallerID.lua:31: in main chunk
_________________________________________________________________________ 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
-- Mit freundlichen Grüßen *Karsten Horsmann*
Dare I ask why you’re doing this? Seems weird to call lua to call python… seems like the wrong approach to me. Maybe outline what you’re trying to accomplish and maybe I could recommend a more sane approach. -- Brian West brian@freeswitch.org FreeSWITCH Solutions, LLC PO BOX 2531 Brookfield, WI 53008-2531 Twitter: @FreeSWITCH , @briankwest http://www.freeswitchbook.com http://www.freeswitchcookbook.com T: +1.918.420.9001 | F: +1.918.420.9002 | M: +1.918.424.WEST iNUM: +883 5100 1420 9001 ISN: 410*543 Skype:briankwest PGP Key: http://www.bkw.org/key.txt (AB93356707C76CED) On Jan 4, 2014, at 4:24 AM, Karsten Horsmann <khorsmann@gmail.com> wrote:
Hi Joli,
is that FS current master or 1.2? In master is 5.2 lua included, in 1.2 is 5.1 Version.
You could test your lua script with the full-path to the python script. Maybe the current working directory of lua is diffrent.
pythonResult = assert (io.popen ('/usr/bin/python /my/full/path/python2lua.py ' ..callerID))
participants (5)
-
Brian West
-
Erik M. Devane - Comms Guy
-
Joli Martinez
-
Karsten Horsmann
-
Steven Ayre