0
votes

In a Lua script, i am making some redis calls and also want to write some text data to a file as well. But when I am executing this lua script from redis using '--eval', it is not able to recognize 'io' or 'require' libraries and hence not able to execute.
Please if you can tell me if there is a way that i can write data to a file in lua when i am calling lua script from redis.

Note : command that i am executing : ' /opt/redis/src/redis-cli -p 6379 --eval test.lua '

in test.lua, it fails in line : " file = io.open("output.txt", "a") "
it shows me the error message : Script attempted to access unexisting global variable 'io'

1

1 Answers

0
votes

Read the documentation about the use of Lua in Redis - it is under the EVAL command.

Specifically, note that Redis' Lua is sandboxed and provides only a subset of the libraries. Theio library is not a part of this subset.