Why can't I interact with redis-cli via fabric? Why can't I interact with redis-cli via fabric? shell shell

Why can't I interact with redis-cli via fabric?


I think this is due to the fact redis-cli in interactive mode is really designed to work with a terminal, while fabric probably runs redis-cli redirecting standard input/output file descriptors.

For instance, the following command works fine:

python | cat

while the following one does not:

redis-cli | cat

redis-cli and the linenoise library providing readline-like facilities do not flush correctly the output with a non terminal file descriptor. A possible workaround which I have not tried with fabric, is to deactivate linenoise:

TERM=dumb redis-cli | cat

By defining the TERM variable to dumb, linenoise defaults on a very basic code path which happens to use a simple printf to deal with the prompt and flush the output just after its display. It may solve your issue with fabric provided you can set this variable in the process environment.


I just found a simple and cool answer; send whatever command you want through echo and pipe:

  • echo "keys *" | redis-cli
  • or specifically for your case: run("echo 'keys *' | redis-cli")