will net so ganz....

Alles, was Perl betrifft, kann hier besprochen werden.

will net so ganz....

Postby MPL » 30. March 2006 16:46

huhu habe mir lampp die neuste version audn linux insaliert... debian 3.1 woody


und wollte jetz en script öffnen das unten steht...... nur es will net ganz der medet mir nen error


/opt/lampp/htdocs/bans# ./move_bans.pl
DBI connect('dbname=bans;host=127.0.0.1','root',...) failed: Client does not support authentication protocol requested by server; consider upgrading MySQL client at ./move_bans.pl line 87
Can't call method "prepare" on an undefined value at ./move_bans.pl line 43.


wat stimmt den da net ??


thx


hier noch das script


move_bans.pl


#!/usr/bin/perl

# AMXBans, managing bans for Half-Life modifications
# Copyright (C) 2003, 2004 Ronald Renes / Niek Albers
#
# web : http://www.xs4all.nl/~yomama/amxbans/
# mail : yomama@xs4all.nl
# ICQ : 104115504
#
# This file is part of AMXBans.
#
# AMXBans is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# AMXBans is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with AMXBans; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#

use strict;
use DBI;

my $dsn = {
host => '127.0.0.1',
username => 'root',
password => 'password',
database => 'bans',
};

main();

sub main {
my $dbh = connect_db($dsn);

my $sth = $dbh->prepare(
q/ SELECT *
FROM amx_bans
WHERE ban_created + ban_length*60 < UNIX_TIMESTAMP()
AND ban_length != 0 /
);

my $rv = $sth->execute();

while ( my $r = $sth->fetchrow_hashref ) {
my $sql = q/INSERT INTO amx_banhistory
(bhid,
player_ip, player_id, player_nick,
admin_ip, admin_id, admin_nick,
ban_type, ban_reason, ban_created, ban_length,
server_ip, server_name, unban_created, unban_reason,
unban_admin_nick)
VALUES ('',?,?,?,?,?,?,?,?,?,?,?,?,?,'Bantime expired','amxbans')/;

my $sth = $dbh->prepare($sql);
my $rv = $sth->execute(
$r->{player_ip}, $r->{player_id}, $r->{player_nick},
$r->{admin_ip}, $r->{admin_id}, $r->{admin_nick},
$r->{ban_type}, $r->{ban_reason}, $r->{ban_created},
$r->{ban_length}, $r->{server_ip}, $r->{server_name},
time()
)
or die $DBI::errstr;

$sth = $dbh->prepare(q/DELETE FROM amx_bans WHERE bid = ?/);
$sth->execute( $r->{bid} );

}

}

sub connect_db {
my ($dsn) = @_;

my @dsnlist = (
'dbi:' . 'mysql' . ':dbname=' . $dsn->{database} . ';host=' .
$dsn->{host},
$dsn->{username}
);
return DBI->connect( @dsnlist, $dsn->{password} ) or die $DBI::errstr;

}
MPL
 
Posts: 59
Joined: 12. February 2006 22:54

Postby deepsurfer » 30. March 2006 16:59

wenn ich mich jetzt nicht irre versteht der MySQL Version 5 diese Befehl "prepare" nicht mehr.
Müsste man in der MySQL-Doku nachschauen, weil bei MySQL4 gibst den wohl.
chirio Deep
Wie sagte einst der MCP aus Tron auf dem Bildschirm zu schreiben Pflegte
" ... end of communication ... "
User avatar
deepsurfer
AF Moderator
 
Posts: 6440
Joined: 23. November 2004 10:44
Location: Cologne
Operating System: Win-XP / Win7 / Linux -Debian

Postby MPL » 30. March 2006 17:09

was soll ich jetz machen???
MPL
 
Posts: 59
Joined: 12. February 2006 22:54

Postby Wiedmann » 30. March 2006 17:18

Woher hast du das DBI Modul für Perl?
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby MPL » 30. March 2006 17:37

öhm.... übers webmin über cpan instaliert
MPL
 
Posts: 59
Joined: 12. February 2006 22:54

Postby Wiedmann » 30. March 2006 17:42

Webmin "kenn" ich nicht...

Jedenfalls hat CPAN dann zum kompilieren die wohl auch auf deinem Rechner vorhandene MySQL 4er Client-Lib genommen und nicht eine 5er Client-Lib (am besten die von XAMPP).
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby MPL » 30. March 2006 17:44

öhm wie soll ih das jetz ändern??

hast vllt ein kompilliertes modul das funzt? kannste es mir geben? und auch noch bitte erkläre wie ich das instaliere were echt cool :]
MPL
 
Posts: 59
Joined: 12. February 2006 22:54

Postby Wiedmann » 30. March 2006 18:05

Sorry, ich benutz und hab kein Linux...

Brauchst du das 4er MySQL-Client überhaupt auf deinem Rechner? Sonst installiere doch den 5er und kompiliere das Modul nochmals neu wie zuvor.

Wenn du es selber machen willst, und das XAMPP MySQL benutzen willst, dann brauchst du erst das XAMPP-Devel Paket. Wie man das Modul von Hand installiert, insb. wie man den Pfad zu MySQL beim Configure angibt, findest du in der Doku zu diesem Modul bei CPAN.
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby MPL » 30. March 2006 18:07

menno bin ein voll n00b in linux bekomme da kaum as zum laufen -.-


habe das dev packet instaliert weiter weiss ich net
MPL
 
Posts: 59
Joined: 12. February 2006 22:54


Return to Perl

Who is online

Users browsing this forum: No registered users and 3 guests