When you want to use curl, you need REST over RESP, like webdis, tinywebdis or turbowebdis. See https://github.com/markuman/tinywebdis#turbowebdis-tinywebdis--cherrywebdis
$ curl -w '
' http://127.0.0.1:8888/ping
{"ping":"PONG"}
Without a REST interface for redis, you can use netcat for example.
$ (printf "PING
";) | nc <redis-host> 6379
+PONG
For password protected redis you can use netcat like this:
$ (printf "AUTH <password>
";) | nc <redis-host> 6379
+PONG
With netcat you have to build the RESP protocol by your self. See http://redis.io/topics/protocol
update 2018-01-09
I've build a powerfull bash function which pings the redis instance at any cost over tcp
function redis-ping() {
# ping a redis server at any cost
redis-cli -h $1 ping 2>/dev/null ||
echo $((printf "PING
";) | nc $1 6379 2>/dev/null ||
exec 3<>/dev/tcp/$1/6379 && echo -e "PING
" >&3 && head -c 7 <&3)
}
usage redis-ping localhost
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…