<div>Hi! Is there any way to pass parameters to a Lua script, or to call a particular function within a lua script, when calling it with the "lua" command from the console? (I can accomplish what I need using global_setvar, but that's an extra step for the user.)</div>
<div> </div>
<div>I'm looking for something more like this:</div>
<div> </div>
<div> <a href="mailto:freeswitch@internal">freeswitch@internal</a>> lua MyFunction("myContents") in MyLuaScriptFile.lua</div>
<div> </div>
<div>Alternatively, is there a way to get input from the console, or otherwise interact with the user? Such as:</div>
<div> stream:write("Enter user name:")</div>
<div> cUserName = stream:readln() -- :-)</div>
<div> </div>
<div> </div>
<div>For anyone who is curious, the global_setvar method of passing info to a script can be done like this...</div>
<div> </div>
<div>In the console, set the global variable(s), then call the script:</div>
<div> </div>
<div> freeswitch@internal> global_setvar myparameter=My Contents</div>
<div> freeswitch@internal> lua MyLuaScriptFile.lua</div>
<div> </div>
<div>(Note that there were no quotes around the string.) And in the script:</div>
<div> </div>
<div> fsapi = freeswitch.API();</div>
<div> myParameter = fsapi:execute("global_getvar", "myparameter")</div>
<div> if string.len(myParameter) == 0 then</div>
<div> -- Global variable does not exist or is empty!</div>
<div> stream:write('ERROR: Please use "global_setvar myparameter=My Contents'"to specify user.\n')</div>
<div> return false</div>
<div> else</div>
<div> -- We retrieved contents of global. </div>
<div> -- Might want to clean out the global to avoid later confusion.</div>
<div> fsapi.:execute("global_setvar", "myparameter=")</div>
<div> end</div>
<div> </div>
<div> </div>