I have the "Hello World" program in Lua script. I am trying to call the script from (Chocolatey) Redis client. I keep getting this error (error) ERR Error compiling script (new function): user_script:1: function argument expected near '.'
<strong>Redis Script: "hello.lua"</strong>
local msg = "Hello, world!" return msg
<strong>Chocolatey Redis Client:</strong>
127.0.0.1:6379> EVAL "D:\hello.lua" 0
(error) ERR Error compiling script (new function): user_script:1: function argument expected near '.'Answer1:
<a href="http://redis.io/commands/eval" rel="nofollow">
EVAL</a> accepts the <strong>script itself</strong>, not a filename.
EVAL 'local msg = "Hello, world!" return msg' 0
<strong>EDIT:</strong> to execute a script in a file,
redis-cli provides the
--eval switch that you can use as follows:
redis-cli --eval <path-to-script-file> [key1 [key2] ...] , [arg1 [arg2] ...]
I'm not familiar with the Windows fork, but it should be supported by it as well in all likelihood.
In *nix, you can also use the shell to provide the contents of the script to the cli, for example:
redis-cli SCRIPT LOAD "$(cat path-to-script-file)"
will load the contents in the file to Redis. There should be a similar way for achieving this in Windows but that's outside my current scope ;)