I just discovered there's a much better of accomplishing what follows. Look for the -X option in the GNU screen manual.
Here's a nice combination of hacks I've got working. It's for when you're running qwsv on a Linux box with the qwrap Perl script and GNU screen for easy adminning. The ultimate goal in my case was automated rebooting of QuakeWorld servers to avoid the slow rocket bug, but you could use it to plug a URL every hour or any other automated server admin task.
I presume the hack would also work for newer Quake servers, e.g. Quake II and Quake III Arena, but I haven't tried.
Firstly, you need to compile tiocsti.c with gcc and call the binary tiocsti:
gcc tiocsti.c -o tiocsti
Next you need a shell script, which is named wall_servers.
This script takes one parameter which is a command to feed to all
servers on the currently running machine. It needs zsh, but if you haven't got zsh installed, you
could easily make it work under bash or whatever. It should be in the
same directory as the tiocsti program (that's what the
$0:h
bit means).
Finally, stick something like this in your root's crontab file (unfortunately I think it has to run as root due to the way Linux only operates with controlling terminals/session groups):
30 5,17 * * * /PACK/Quake/default/servers/screen-hacking/wall_servers 'say "[auto-msg] server rebooting in 30 minutes"' 35 5,17 * * * /PACK/Quake/default/servers/screen-hacking/wall_servers 'say "[auto-msg] server rebooting in 25 minutes"' 40 5,17 * * * /PACK/Quake/default/servers/screen-hacking/wall_servers 'say "[auto-msg] server rebooting in 20 minutes"' 45 5,17 * * * /PACK/Quake/default/servers/screen-hacking/wall_servers 'say "[auto-msg] server rebooting in 15 minutes"' 50 5,17 * * * /PACK/Quake/default/servers/screen-hacking/wall_servers 'say "[auto-msg] server rebooting in 10 minutes; maxclients set to 0"'; /PACK/Quake/default/servers/screen-hacking/wall_servers 'maxclients 0' 55 5,17 * * * /PACK/Quake/default/servers/screen-hacking/wall_servers 'say "[auto-msg] server rebooting in 5 minutes"' 58 5,17 * * * /PACK/Quake/default/servers/screen-hacking/wall_servers 'say "[auto-msg] server rebooting in 2 minutes"' 59 5,17 * * * /PACK/Quake/default/servers/screen-hacking/wall_servers 'say "[auto-msg] server rebooting in 1 minute"' 0 6,18 * * * /PACK/Quake/default/servers/screen-hacking/wall_servers 'say "[auto-msg] server rebooting NOW; please reconnect"'; /PACK/Quake/default/servers/screen-hacking/wall_servers 'quit'
Note that the funny character there is a ^U (ASCII 21), for ensuring that the line is empty before inputting anything. If it makes your life easier, the above crontab snippet is available for download.
There you have it. Thanks to Alasdair Kergon for the
ioctl()
idea.
Last updated: Sat Nov 1 22:37:39 2003
© 1995-2003
Adam Spiers <adam@spiers.net>