Created
October 17, 2013 20:32
-
-
Save o11c/7031720 to your computer and use it in GitHub Desktop.
This is a script to check if a TMW server is alive. By default, it checks the main server, but it takes 2 optional arguments: the hostname and the port. You can finger the login server and the char server, but not the map server. For example,
$ tmwa-finger caliban.homeip.net
$ tmwa-finger server.themanaworld.org 6902
$ tmwa-finger server.themana…
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/bash -e | |
| SERVER=${1:-server.themanaworld.org} | |
| PORT=${2:-6901} | |
| die() { | |
| echo "$1" >&2 | |
| exit 1 | |
| } | |
| readbyte() { | |
| local byte REPLY | |
| read -N1 | |
| byte=$(printf %d \'"$REPLY") | |
| read $1 <<< "$byte" | |
| } | |
| readword() { | |
| local low high | |
| readbyte low | |
| readbyte high | |
| read $1 <<< $((high*256 + low)) | |
| } | |
| nonzero() { | |
| test $1 -eq 1 | |
| } | |
| echo -n 0u | nc $SERVER $PORT | { | |
| readword packet | |
| nonzero $((packet == 0x7531)) || die "wrong packet" | |
| readbyte major | |
| readbyte minor | |
| readbyte patch | |
| readbyte develop | |
| readbyte flags | |
| readbyte which | |
| readword vendor | |
| echo TMWA $major.$minor.$patch dev$develop flags$flags which$which vendor$vendor | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment