Created
September 2, 2016 11:50
-
-
Save serac/7bba39e70a983b2b2d21245072b0bd05 to your computer and use it in GitHub Desktop.
Bash script to get a key from a list of memcached hosts, testing each one in turn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function getkey { | |
echo "Checking $M for $2" | |
HOST=$(echo $1 | cut -d':' -f1) | |
PORT=$(echo $1 | cut -d':' -f2) | |
echo "get $2" | nc -w1 $HOST $PORT | |
} | |
if [ $# -lt 1 ]; then | |
echo "USAGE: $(basename $0) keyname" | |
exit | |
fi | |
trap "exit" SIGINT SIGTERM | |
IFS=',' | |
for M in $MEMCACHED_HOSTS; do | |
getkey $M $1 | |
done | |
unset IFS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage Example: