Urban Terror Forums: Server Messaging with Linux - Urban Terror Forums

Jump to content

 Login | Register 
Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Server Messaging with Linux Rate Topic: -----

#1 User is offline   faebuk Icon

  • Account: faebuk
  • Main tag: =vSC=
  • Country:
  • Joined: 28-August 10
  • Posts: 4

Posted 27 January 2013 - 09:48 PM

I have several of urban terror server, and I wrote a script which checkes for something and removes it. So I check it with a a little bash script on my linux maschine and it works. This is what I used:


printf '\xFF\xFF\xFF\xFFrcon rconpassword rconbefehl\n' | nc -u -n -w 1 ip port | sed -ne ':x;/\xFF/{N;s/\xFF\xFF\xFF\xFFprint\n//;tx};/^$/d;p'

like I said the script works but it has 1387 lines of code because the for-loop in bash didnt work. So here is it how I tried with the for-loop:


for i in 18
player = i
printf '\xFF\xFF\xFF\xFFrcon rconpassword dumpuser $i\n' | nc -u -n -w 1 ip port | sed -ne ':x;/\xFF/{N;s/\xFF\xFF\xFF\xFFprint\n//;tx};/^$/d;p'

this doesnt work so my main question about it: is there another way to do it or what is wrong with it?


#2 User is offline   ItsMe Icon

  • Account: itsme
  • Main tag: bc`
  • Joined: 28-February 10
  • Posts: 76

Posted 02 February 2013 - 12:46 PM

View Postfaebuk, on 27 January 2013 - 09:48 PM, said:

for i in 18
player = i
printf '\xFF\xFF\xFF\xFFrcon rconpassword dumpuser $i\n' | nc -u -n -w 1 ip port | sed -ne ':x;/\xFF/{N;s/\xFF\xFF\xFF\xFFprint\n//;tx};/^$/d;p'

Your code can't work for a couple of reasons.
The error you get comes from the missing '':

printf '\xFF\xFF\xFF\xFFrcon rconpassword dumpuser [b]'[/b]$i[b]'[/b]\n' | nc -u -n -w 1 ip port | sed -ne ':x;/\xFF/{N;s/\xFF\xFF\xFF\xFFprint\n//;tx};/^$/d;p'

The next problem will be the slotnumbers.
I think your server has 18 slots so you go though the loop with the count of 18. But that will not work all the time.

Joe joins the server -> slot 1
Jane joins the server -> slot 2
Frank joins the server -> slot 3
Mark joins the server -> slot 4

Jane leaves the server -> slot 2 is empty and your script will output: Player 2 is not on the server

This (quick and dirty) script should do the trick:

#! /bin/bash
# OK lets work

# generate a genuine tempfile
tmpfile="/tmp/$(basename $0).$$.tmp"

# get all Slots that are used by players on the server and write it to the tempfile
printf '\xFF\xFF\xFF\xFFrcon shangrila status\n' | nc -u -n -w 1 47960 | sed -ne ':x;/\xFF/{N;s/\xFF\xFF\xFF\xFFprint\n//;tx};/^$/d;p' | awk '{printf "%g\n" ,$1}' | sed -e '/^0/d' > $tmpfile

# read the content tempfile and print the result of dumpuser to standard output
cat $tmpfile | \
while read CMD; do
        printf '\xFF\xFF\xFF\xFFrcon shangrila dumpuser '$CMD'\n' | nc -u -n -w 1 47960 | sed -ne ':x;/\xFF/{N;s/\xFF\xFF\xFF\xFFprint\n//;tx};/^$/d;p'


You can download the script here:

md5sum: d8ad885ed814e7a6b1d8963df9de33b7

PS: don't forget to change the server address/ port and rcon password to your needs

This post has been edited by ItsMe: 02 February 2013 - 01:46 PM

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users

Sponsored link

Copyright © 1999-2022 Frozensand Games Limited  |  All rights reserved  |  Urban Terror™ and FrozenSand™ are trademarks of Frozensand Games Limited

Frozensand Games is a Limited company registered in England and Wales. Company Reg No: 10343942