Hi there,
i'm new to this Forum, but not new to ArmA. I'm supporting ArmA since OFP and do my best spreading the word about this awesome non-arcade-military-game.
I have a warfare server for CO/OA which is runnin fine, from the generated serverlog.txt I extract some stats (egrep discards useless data for me) like this:
It's a linux machine and I'd like to generate some small stats tables from this textfile, therefore I've written a php-script that takes these 4 values and writes them into a MySQL-Database. Now the only thing I need is awk to generate some useable SQl syntax from this parsed serverlog file.name="mich@l *cz*";
customScore=24;
killsTotal=53;
killed=2;
name="INF_tr0y";
customScore=0;
killsTotal=1;
killed=0;
name="Mr Chivas";
customScore=0;
killsTotal=0;
killed=0;
name="[HB] Philipp";
customScore=0;
killsTotal=0;
killed=0;
name="[HB]Dan";
customScore=0;
killsTotal=0;
killed=0;
I'm not familiar with awk, and here's the error. It generates from above values not the needed SQL syntax:
What I expected is something like this:PHP Code:SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
CREATE TABLE IF NOT EXISTS `phpkit2`.`Players` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL AUTO_INCREMENT,
`customScore` int(11) NOT NULL,
`killsTotal` int(11) NOT NULL,
`killed` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs;
INSERT INTO `Players` (`name`, `customScore`, `killsTotal`, `killed`) VALUES
(1, name="Ats Puu", ^M, ),
(2, customScore=1, ^M, ),
(3, killsTotal=6, ^M, ),
(4, killed=3, ^M, ),
(5, name="Dennis2000", ^M, ),
maybe someone of you guys can help getting this lil thing done, so we can make a bundle for server-owners to generate their own lil stats...PHP Code:SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
CREATE TABLE IF NOT EXISTS `phpkit2`.`Players`(
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) character set utf8 collate utf8_bin NOT NULL default '',
`customScore` int(11) NOT NULL,
`killsTotal` int(11) NOT NULL,
`killed` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `name` (`name`)
)ENGINE=MyISAM DEFAULT CHARSET=utf8;
INSERT INTO `Players` (`name`, `customScore`, `killsTotal`, `killed`) VALUES
('Ats Puu', '1', '6', '3'),
('Peter', '2', '8', '4');
Here's my faulty awk source which should be executed by a cron-job:
Maybe some helpful guy can teach me how to rewrite the awk script to generate a useable SQL STATEMENT (awk -f awkscript serverlog.txt > inc.stats.php.BEGIN {
FS=";"
printf "SET SQL_MODE=\"NO_AUTO_VALUE_ON_ZERO\";\n"
printf "CREATE TABLE IF NOT EXISTS `phpkit2`.`Players` (\n"
printf " `id` int(11) NOT NULL AUTO_INCREMENT,\n"
printf " `name` varchar(100) NOT NULL AUTO_INCREMENT,\n"
printf " `customScore` int(11) NOT NULL,\n"
printf " `killsTotal` int(11) NOT NULL,\n"
printf " `killed` int(11) NOT NULL,\n"
printf " PRIMARY KEY (`id`),\n"
printf " KEY `name` (`name`)\n"
printf ") ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs;\n"
printf "INSERT INTO `Players` (`name`, `customScore`, `killsTotal`, `killed`) VALUES\n"
}
{
{if (NR == 1) printf ""
else printf ",\n"}
printf "(" NR ", "
printf $1", "
printf $2", "
printf $3")"
}
END{
printf ";\n"
}
I tried many howto's and websites to get behind the internal work of AWK, but I only understand that it's parsing the lower part of the awkscript once per line in serverlog.txt
help may be apreciated,
raz0rsedge
http://silent-forces-clan.de/sfc/inc...layerstats.php
HOME
Reply With Quote


