有问题redis-cli。我想redis通过 BASH检查连接是否被拒绝(服务器关闭)。
简单测试
#!/bin/bash
test=$(redis-cli exit) #exit out of the "not connected console"
if [[ -z $test ]] ; then
echo "I'm empty :("
fi
Run Code Online (Sandbox Code Playgroud)
我希望Could not connect to Redis at 127.0.0.1:6379: Connection refused存储在 $test 中,但此文本会输出到控制台。
我不确定发生了什么。谁有想法?
(Ubuntu 14.04.1)