Reputation: 109
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 '.'
Redis Script: "hello.lua"
local msg = "Hello, world!"
return msg
Chocolatey Redis Client:
127.0.0.1:6379> EVAL "D:\hello.lua" 0
Error Message
(error) ERR Error compiling script (new function): user_script:1: function argument expected near '.'
Upvotes: 1
Views: 2384
Reputation: 49942
EVAL
accepts the script itself, not a filename.
Try this:
EVAL 'local msg = "Hello, world!" return msg' 0
EDIT: 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 ;)
Upvotes: 6