4
votes

I am trying to pass an argument to my Redis Lua script using the following syntax:

redis-cli -h 127.0.0.1 -p 6379 -a my-super-secret-auth-key --eval /tmp/test.lua 0 60

However in my script when I do: print (ARGV[1]);

I get (nil) returned. What am I doing wrong? How can I properly pass an argument to my script?

1

1 Answers

6
votes

You need to use comma (,) to separate KEYS and ARGV parameters even when you don't pass any KEYS (assuming you want 0 and 60 to be passed as ARGV):

redis-cli -h 127.0.0.1 -p 6379 -a my-super-secret-auth-key --eval /tmp/test.lua , 0 60

In your case these parameters are taken as KEYS, not as ARGV parameters. See Running Lua scripts in the Redis docs.