Now that the NAS can pass args into a Lua script, what is the syntax to reference them and print the number of args passed?
I haven't used this from within NAS, but assuming it is the same as the NSA then the arguments are in a variable called SCRIPT_ARGUMENT, which you will need to parse within your script, e.g.
parms = split(SCRIPT_ARGUMENT)
for i,p in ipairs(parms) do
Thanks, that works for the NAS too.
I try to pass argument from nsa in a script but a reieved always a error ?
I use the next command ;
nsa args -atest
I received the new message :
Jun 18 13:26:28:743 nsa: Script error, args:3: bad argument #1 to 'split' (string expected, got nil)
--Reference Args passed from NAS into a Lua Scriptparms = split(SCRIPT_ARGUMENT)for i,p in ipairs(parms) doprint (p)
Have somebody a idee ?
I think you might just need to put a space between the -a option and the argument you are sending into the script ("test" in this case). It looks like there is no space there in the command you pasted above.
Yes, this is correct. The split function actually takes two arguments. The first is the string to split and the optional second argument is the character(s) to split on. The default is whitespace. Hence -atest comes out as one string while '-a test' would come out at '-a' and 'test'.
Retrieving data ...