linux dedicated server trick w/screen


(tjw) #1

For those who run etded servers inside of GNU screen on Linux, here’s a neat trick.

Install the following bash script in your PATH (e.g. /usr/local/sbin/etconsole):


#!/bin/bash
###############################################################################
# This script runs a command in the console of a etded.x86 process that is 
# running in a screen.
#
# Edit the SCREEN_SEARCH variable to match your system
#
###############################################################################

SCREEN_SEARCH="SCREEN -d -m chroot /usr/local/enemy-territory su - et "

spid=`ps auxww | grep "${SCREEN_SEARCH}" | grep -v grep | awk '{print $2}'`;
cmd=$@$'\xA'
screen -S $spid -X stuff "$cmd"

You will then be able to send commands to the running etded console with the etconsole command. For example:


etconsole "say this is a test"

The above would be just like typing ‘say this is a test’ in your server console.

Note that you will most certainly need to change the SCREEN_SEARCH variable unless you’ve set up your et server exactly like I have (http://tjw.org/etded/)

The main reason I’ve set this up is so that I can automate certain server setting changes with cron (e.g. Panzer Free Friday).

Update: use /bin/bash instead of /bin/sh as interpreter.


(Deprave) #2

Excellent post tjw…and ive always liked the ets perl script you use if you see ive implemented at my server www.migamer.com
but i will be using this script…can tell it will be a real time saver…probably makes it easier then typing screen -r and then trying to type with a full server also…now i move onto the cron scripts… :eek2: :smiley: :eek2: Thanks for keeping it real on your site and for all the usefull shrub admin/linux tips


(Lekdevil.NL) #3

Nifty, although something isn’t quite working. When I use your script, for instance with:


./etconsole "say bla bla bla"

I get the following text in the server console:


say bla bla bla$\xA

and the line doesn’t get executed until I hit the enter key manually. Obviously the newline character in the script doesn’t get “escaped” properly. Any ideas how to fix this?

Added: Nevermind. I got it. Seems I was using the wrong shell. Using bash fixed things.