Last active
May 21, 2016 03:00
-
-
Save travis-g/1f5819b1d9eb8b0af88bfa91245d5310 to your computer and use it in GitHub Desktop.
Online player info of Minecraft servers
This file contains hidden or 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/sh | |
help () { | |
cat <<EOF | |
usage: $(basename $0) [-hcl] | |
-h print this help | |
-c print player count (default) | |
-l list player names | |
environment: | |
PORT the server port, default 25565 | |
SERVER the server script/daemon, default ~/minecraft | |
EOF | |
} | |
test "$1" = "-h" && help && exit 0 | |
# env | |
PORT=${PORT:-25565} | |
SERVER=${SERVER:-~/minecraft} | |
NUM=`netstat -anp 2>/dev/null | grep :$PORT | grep ESTABLISHED | wc -l` | |
list () { | |
$SERVER command '/list' | tail -n $NUM | rev | cut -d" " -f1 | rev | |
} | |
case $1 in | |
-h) help ;; | |
-l) list ;; | |
*) echo $NUM ;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment