在 Freeswitch 中,传递给 lua 脚本的参数是用空格分隔的(参见http://wiki.freeswitch.org/wiki/Mod_lua#Passing_Arguments)。
我已经确定您可以将参数用单引号括起来,然后忽略空格,但我无法弄清楚如何转义单引号。
应该如何将带空格的参数传递给 Lua?
要重现问题:
示例 Lua 脚本:
argumentOne=argv[1];
argumentTwo=argv[2];
argumentThree=argv[3];
argumentFour=argv[4];
freeswitch.consoleLog("info", "*******************\n");
freeswitch.consoleLog("info", argumentOne);
freeswitch.consoleLog("info", "\n");
freeswitch.consoleLog("info", argumentTwo);
freeswitch.consoleLog("info", "\n");
freeswitch.consoleLog("info", argumentThree);
freeswitch.consoleLog("info", "\n");
freeswitch.consoleLog("info", argumentFour);
freeswitch.consoleLog("info", "\n");
freeswitch.consoleLog("info", "*******************\n");
这工作正常:
freeswitch@internal> luarun luaargumenttest.lua one two 'thr ee' four
+OK
freeswitch@internal> 2012-06-24 11:56:55.873757 [INFO] switch_cpp.cpp:1197 *******************
2012-06-24 11:56:55.873757 [INFO] switch_cpp.cpp:1197 one2012-06-24 11:56:55.873757 [INFO] switch_cpp.cpp:1197
2012-06-24 11:56:55.873757 [INFO] switch_cpp.cpp:1197 two2012-06-24 11:56:55.873757 [INFO] switch_cpp.cpp:1197
2012-06-24 11:56:55.873757 [INFO] switch_cpp.cpp:1197 thr ee2012-06-24 11:56:55.873757 [INFO] switch_cpp.cpp:1197
2012-06-24 11:56:55.873757 [INFO] switch_cpp.cpp:1197 four2012-06-24 11:56:55.873757 [INFO] switch_cpp.cpp:1197
2012-06-24 11:56:55.873757 [INFO] switch_cpp.cpp:1197 *******************
但是我将如何发送参数值“three's a crowd”?
我试过 \', '', ''' 和 " and \" 但这些都不起作用。