Category Archives: Development

Redis: print to STDOUT from a LUA script

When you want to print to STDOUT from a LUA script executed by “redis-cli –raw –eval”, it doesn’t print to STDOUT but in Syslog. You will need to use “return” instead.

Let’s help yourself with a “logit” function, like this:

local log = {}
local function logit(msg)
  log[#log+1] = msg
end

-- Some code

    -- Log my string
    logit(mystring)

-- Some more code

-- print log to STDOUT
return log

That’s awesome till you don’t know how to pass arguments to your Redis LUA script ! :-)

Redis: passing args to a LUA script

How did it came in their brain that the arguments where not stored in the ARG[] array but in the KEYS[] one ?

So if you want to call your Redis LUA script this way:

redis-cli --raw --eval myscript.lua arg1 arg2 ...

You have to access your args this way in the LUA script:

local arg1=KEYS[1]
local arg2=KEYS[2]
...

That’s awesome till you don’t know how to STDOUT print some results :-)

STARTTLS for ClamSMTP server

I didn’t find any patch to enable STARTTLS on client side in ClamSMTP when accepting direct (port 25) connexions, so I wrote it.

You can find my code here on GitHub : https://github.com/beaujean/ClamSMTP-TLS/

Two options have been added to the clamsmtp.conf file:

TLSKey: /path/to/file.key
TLSCert: /path/to/file.crt

It’s originally from http://thewalter.net/stef/software/clamsmtp/ by Stefan Walter. A git repository was actually here http://thewalter.net/git/cgit.cgi/clamsmtp/ but didn’t include the /common/ directory.