Re: Linux Admining
Im rather proud of this altho it will make others cringe at its ugliness. I wanted a way for people to check which games need players. Doing an "ls" of the game directory from a CGI was easy enough but I realized that instead of using "ls" of the directorys as fact that the game exists, I should use the "ps". Then starting a game will automatically cause it to show, and if a game finishes or crashes then it will automatically not appear. I also arranged for it to pull the port from the ps display and show that.
http://host.dom3minions.com/bin/blitz_chk.cgi
Code:
#!/bin/bash
echo "Content-type: text/html"
echo -e "\n\n"
echo "<H2><b>Dominions 3 Blitz games</b></H2>"
echo "These are 2-player games on tiny maps<br>"
echo '<a href="http://host.dom3minions.com/how-to.html">how to join a game</a><b
r><br>'
cd /home/dom3/dominions3/savedgames
ps ax |grep dom3|grep bl_ | \
while read n n n n n n game n port n n n n n n n n era n
do
echo "era $era game <b>$game</b> on port <b>$port</b><br>"
cd $game
for fyle in `ls -1 *.2h`
do
echo $fyle "<br>"
done
cd /home/dom3/dominions3/savedgames
echo "<br>"
done
__________________
-- DISCLAIMER:
This game is NOT suitable for students, interns, apprentices, or anyone else who is expected to pass tests on a regular basis. Do not think about strategies while operating heavy machinery. Before beginning this game make arrangements for someone to check on you daily. If you find that your game has continued for more than 36 hours straight then you should consult a physician immediately (Do NOT show him the game!)
|