1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/perl -w
#DatenbankAbfragen
use strict;
use Mysql;
our $dbh;
my @raw_data;
my @sqldata;
my $rc;
sub Query{
my $query;
my $sth;
my $execu;
my $newdata;
my $ds;
$query = "SELECT RC_CISCO.ID, RC_CISCO.NEID, RC_CISCO.TS, RC_CISCO.BState,RC_CISCO.Data_CISCO,RC_CISCO.MD5 FROM RC_CISCO";
$sth = $dbh->prepare($query) or die "Querry Error prepare: $DBI::errstr\n";
$ds = $sth->execute or die "Querry Error execute: $DBI::errstr\n";
while($newdata = $sth->fetchrow_hashref) #Holt die nächste Zeile als eine Referenz einer Hash-Tabelle.
{
print "ID:$newdata->{ID} Name:$newdata->{NEID} Name:$newdata->{BState} Name:$newdata->{Data_CISCO} Name:$newdata->{MD5}\n";
}
$sth->finish();
}
open(DAT, "../gate_common/MySQLAccount.txt") || die("Could not open SQL-Data-file!");
@raw_data=<DAT>;
close(DAT);
@sqldata = split(/:/, $raw_data[0]);
print "host ".$sqldata[0]."\n"."user ".$sqldata[1]."\n"."pass ".$sqldata[2]."\n"."db ".$sqldata[3]."\n";
$dbh = DBI->connect("DBI:mysql:".$sqldata[3].":".$sqldata[0],$sqldata[1],$sqldata[2])|| die "Connect Error: $DBI::errstr()\n";
Query;
$rc = $dbh->disconnect;
Danke !!\n\n
<!--EDIT|renee|1164736790-->