Thread Log files mit DBI auf Microsoft SQL: Datenuebertragung von Linux auf Windows
(14 answers)
Opened by Gast at 2004-06-02 07:16
Hi.
habe fogendes Problem und zwar versuche ich Log FIles von einem Linux server (Red Hat) auf eine Microsoft Sql Datenbank zu schreiben. Habe dafuer einen Programmtext in Perl geschrieben der sieht folgendermassen aus: #!/usr/bin/perl -w use DBI; $file = "/var/log/messages"; unless (open(FH, $file)){ die "error: could not '$file': $!\n; }#if while (defined($getline=<FH>)){ @line=split(/ /, $getline); for ($i=9; $i<scalar(@line);$i+=1) { $line[8]=$line[8].' '.$line[$i]; }#for my $dbh = DBI->connect("dbi:mSQL:T1:fabian:3306","password","fabian"); my $sth=$dbh->prepare("insert into fabian ('month1','day1','time1','ip','port','month2','day2','time2','message') values('".$line[0]."','".$line[1]."','".$line[2]."','".$line[3]."','".$line[4]."','".$line[5]."','".$line[6]."','".$line[7]."','".$line[8]."')"); $sth->execute(); }#while iclose (FH); Habe das mal ausgefuehrt und bekomme Fehlermeldungen ohne Ende. z.B. Possible unintended interpolation of @line in string at ./syslogmsql line 5. Bareword found where operator expected at ./syslogmsql line 13, near "my $dbh=DB (Might be a runaway multi-line "" string starting on line 5) (Do you need to predeclare my?) Unquoted string "dbi" may clash with future reserved word at ./syslogmsql line 1 Unquoted string "fabian" may clash with future reserved word at ./syslogmsql lin String found where operator expected at ./syslogmsql line 13, near "3306","" (Missing operator before ","?) Bareword found where operator expected at ./syslogmsql line 13, near "","passwor (Missing operator before password?) Unquoted string "password" may clash with future reserved word at ./syslogmsql l String found where operator expected at ./syslogmsql line 13, near "password","" Bareword found where operator expected at ./syslogmsql line 13, near "","fabian" (Missing operator before fabian?) Unquoted string "fabian" may clash with future reserved word at ./syslogmsql lin String found where operator expected at ./syslogmsql line 14, near "my $sth=$dbh (Might be a runaway multi-line "" string starting on line 13) (Missing semicolon on previous line?) Bareword found where operator expected at ./syslogmsql line 14, near "my $sth=$d (Do you need to predeclare my?) String found where operator expected at ./syslogmsql line 15, at end of line (Missing semicolon on previous line?) syntax error at ./syslogmsql line 13, near "my $dbh=DBI->connect("dbi" Can't find string terminator '"' anywhere before EOF at ./syslogmsql line 15. Kann mir da aber keinen Reim draus machen wenn jemand weiss was ich da falsch gemacht habe waere ich ueber einen Tip sehr dankbar cu dayspring |