59429

Error while running Lua script from redis client

Question:

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

<strong>Error Message</strong>

(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.

Try this:

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 ;)

Recommend

  • Lua return directory path from path
  • How to redirect after form post with scrapy_splash package?
  • Simple script doesn't show anything on the Output in LuaEdit
  • Calling C function from lua
  • How do I check if System::Collections:ArrayList is empty / nullptr / null?
  • Watson Conversation - Why is the ANYTHING ELSE node not chosen
  • pickle.PicklingError: args[0] from __newobj__ args has the wrong class with hadoop python
  • Using $compile in a directive triggers AngularJS infinite digest error
  • converter json to two dimensional array
  • SetWindowsHookEx does not react on media keys
  • Element.tagName for python not working
  • Graphics.CopyFromScreen [Web application] + The handle is invalid
  • Access variable of ScriptContext using Nashorn JavaScript Engine (Java 8)
  • How solve “Qt: Untested Windows version 10.0 detected!”
  • MySQL Order by column = x, column asc?
  • Install PHP intl extension on MacOS
  • ADO and msqli connections very slow
  • Retrieve list of sent friend requests from friend_request FQL table
  • PHP buffered output depending on server setting?
  • Functions in global context
  • NHibernate Validation Localization with S#arp Architecture
  • DomPDF {PAGE_NUM} not on first page
  • How can I send an e-mail from a vbs script
  • Javascript simulate pressing enter in input box
  • jQuery show() function is not executed in Safari if submit handler returns true
  • Accessing IRQ description array within a module and displaying action names
  • Is possible to count alias result on mysql
  • Check if a string to interpolate provides expected placeholders
  • Where to put my custom functions in Wordpress?
  • Importing jscolor library in angular 2
  • Websockets service method fails during R startup
  • 0x202A in filename: Why?
  • A cron job substitute?
  • Getting Messege Twice Using IMvxMessenger
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • Django query for large number of relationships
  • costura.fody for a dll that references another dll
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • How can I use `wmic` in a Windows PE script?
  • How to push additional view controllers onto NavigationController but keep the TabBar?