Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- port="44400"
- host="localhost"
- rcon_passwd="<your_password>"
- [ -n "$1" ] && port=$1
- [ -n "$2" ] && host=$1 && port=$2
- send() {
- echo -e "\xFF\xFF\xFF\xFFrcon ${rcon_passwd} $*\n\n" | nc -uq 1 ${host} ${port}
- }
- check_connection() {
- response=`send status`
- [ "${response}" = "" ] && return 1 || return 0
- }
- echo -n "$0: connecting... "
- if ! check_connection; then
- echo -e "\n$0: can't connect to ${host}:${port}"
- echo -e "usage: $0 [[<host>] <port>]"
- exit 0
- fi
- echo -e "[ok]\n$0: press ^C or type \"quit\" to exit\n"
- while true; do
- IFS="" read -r -e -d $'\n' -p "> " cmd
- [ "${cmd}" == "quit" ] && exit 0
- send ${cmd} | tail -n+3
- history -s "${cmd}"
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement