Forums » Linux

Print player list while you play.

Aug 30, 2003 birre link
lynx -dump 'http://vendetta.guildsoftware.com/?action=active'|egrep -i '(gold|red|blue|online)'

Make a script, and run it from a text console when you need to check who is online.
Pipe the result to tail -1 of you only need the summary,
or to the printer if you need to get back to the game fast.

/Birre
Sep 03, 2003 Demonen link
Based on birre's post I made the following script.
It gets the playerlist from the page every minute and presents it in a quick and easy form.
I have two computers on my desk. While I'm playing vendetta on one, the other runs this perl script (keep in mind that the board script might mangle the code):

#!/usr/bin/perl
# VULTURE , Vendetta User List Tracker - Update Really Enhanced
# was called just VULT untill I added the "progress bar" :)
#By Demonen of z0rZ -> www.z0rz.net
$| = 1;
&colors;
while ($blah eq undef){
system(clear);
print $C_blink."Updating".$C_reset;
my @data = qx/lynx -dump 'http:\/\/vendetta.guildsoftware.com\/?action=active'|egrep -i '(Gold|Red|Blue|Name)'/;
system(clear);
foreach (@data){
if ($_ =~ m/Gold/){
$_ = $C_brown.$_.$C_reset;
}
if ($_ =~ m/Red/){
$_ = $C_red.$_.$C_reset;
}
if ($_ =~ m/Blue/){
$_ = $C_cyan.$_.$C_reset;
}
$_ =~ s/gold/$C_brown Gold $C_reset/g;
$_ =~ s/red/$C_red Red $C_reset/g;
$_ =~ s/blue/$C_cyan Blue $C_reset/g;
}
system(clear);
print @data;
print $C_reset;
print "\n";
my $dots = 0;
my $dotsd = '';
while ($dots < 59){
$dotsd = $dotsd.'=';
print "\r ";
$countdown = (59 - $dots);
print "update \[".$dotsd.$countdown."\>";
$dotcompare = 0;
while ($dotcompare < (57 - $dots)){
print ' ';
$dotcompare++;
}
print "\]";
sleep(1);
$dots++;
}
}
sub colors{
$C_red = "\033[31m";
$C_brown = "\033[33m";
$C_cyan = "\033[36m";
$C_reset = "\033[0m";
$C_blink = "\033[5m";
}
Sep 03, 2003 roguelazer link
Um. Check out the one I've had on my site for a long time:

http://roguelazer.no-ip.com/cgi-bin/test.cgi

It's hosted on my home computer and I edit it from time to time, so it's not always there. Aah. My apache config is broken again. It doesn't work right. But the script itself is fine, I ran it from a console. :)



SOURCE:

#!/bin/bash

NOTHING=`echo`
DATAFILE="/home/httpd/data/ingamepeople.txt"
TOTALSFILE="/home/httpd/data/ingametotals.txt"



if [ ! -e ${DATAFILE} ]
then
touch ${DATAFILE} > /dev/null 2>&1
fi
if [ ! -e ${TOTALSFILE} ]
then
touch ${TOTALSFILE} > /dev/null 2>&1
chmod 740 ${TOTALSFILE}
fi

exec wget -q -O- http://vendetta.guildsoftware.com/?action=active | html2 2>/dev/null | grep "/html/body/center/table/tr/td/font/table/tr/td\(/font\)*=" | cut -f2 -d= > ${DATAFILE}
exec wget -q -O- http://vendetta.guildsoftware.com/?action=active | html2 2> /dev/null | grep "players --" | cut -d= -f2 > ${TOTALSFILE}

echo "Content-Type: text/html"
echo
echo "<HTML>"
echo "<HEAD><TITLE>This is a test</title></head>"
echo "<BODY>"
echo "<h1>Hello, this is a test.</h1>"
echo "<BR>"
echo "<h2>VENDETTA TOTALS:</h2>"
echo `cat ${TOTALSFILE}`
echo "<BR>"
echo "<h2>VENDETTA PEOPLE</h2>"
if [ `cat ${DATAFILE} | grep Roguelazer` = ${NOTHING} ]
then
echo "<P>Roguelazer's not on, Sorry!</p>"
else
echo "<P>Roguelazer's online RIGHT NOW!!!</p>"
fi
if [ `cat $DATAFILE | grep Arolte` = ${NOTHING} ]
then
echo "<P>Arolte's not on, Sorry!</p>"
else
echo "<P>Arolte's online RIGHT NOW!!!</p>"
fi
if [ `cat $DATAFILE | grep "StarFreeze" && cat ${DATAFILE} | grep "Bank(Vault)" && cat ${DATAFILE} | grep "Bank(Blue)"` = ${NOTHING} ]
then
echo "<P>StarFreeze doesn't appear to be online...</p>"
else
echo "<P>StarFreeze's on!</p>"
fi
if [ `cat ${DATAFILE} | grep "a1k0n" && cat ${DATAFILE} | grep "Incarnate" && cat ${DATAFILE} | grep raybondo && cat ${DATAFILE} | grep Vlad` = ${NOTHING} ]
then
echo "<P>No devs online right now...</p>"
else
echo "<P>A dev is on! Get ingame!</p>"
fi
echo "</body>"
echo "</html>"






This uses a program called html2 instead of lynx -dump, and it outputs plain text. Strange, the one on my website isn't working right. Oh well. It used to work...
Sep 03, 2003 Demonen link
The whole point of my script is that it isn't on the web :)