#!/usr/bin/perl
use DBI qw(:sql_types); # Sql Insert/select
use POSIX qw(strftime); # Date/time conversion
# our way to connect our mysql database An Odbc driver is mandatory for Windows
$database="databasename or dsn";
$hostname="mycomputer";
$login = "databaselogin";
$mdp = "databasepassword";
#linux: $dsn = "DBI:mysql:$database;$hostname";
#windows with ODBC driver mysql-connect-odbc
$dsn = "DBI:ODBC:$database";
$dbh = DBI→connect($dsn, $login, $mdp) or die "Connection Error";
#——————————————————
$requete = "DELETE FROM DayMatchLog WHERE Year=".$year." AND TheMatch=".$match." AND SiteId=2";
$sth = $dbh→prepare($requete);
# We execute the mysql select
$sth→execute();
#——————————————————
$requete = "SELECT * FROM Result";
$sth = $dbh→prepare($requete);
# We execute the mysql select
$sth→execute();
# we grab and use the results
while(my @row = $sth→fetchrow_array)
{
# Everything is in $row[' ']
if ($row['2'] eq "")
{
print "Bof..\n";
}
else
{
my $result = `cd $row['2']`;
my @result_map = split(' ',$result);
# We get the current date time
my $now = strftime("%Y-%m-%d %H:%M:%S", localtime);
print "".$row['0']."-".$result_map[0]."-".$result_map[1]." date:".$now."\n";
# We prepare our insert request with the retrieve values from mysql and df
$requete = "INSERT INTO Result2 Values ($row['0'],\"$now\")";
# we display our sql request
print " [ $requete ]\n";
# we execute our sql request
$sthins = $dbh→prepare($requete);
$sthins→execute();
$sthins → finish;
}
}
# we close the select sql request
$sth → finish;
#——————————————————
# we close the database
$dbh → disconnect
#——————————————————