in reply to No errors listed
#! /usr/bin/perl -wd use strict; #use Carp; use DBI; my $dbname = "passive"; my $dbuser = "scand"; my $dbpass = "redacted"; my $dsn = "DBI:mysql:" . $dbname; # Open the database my $dbh = DBI->connect($dsn, $dbuser, $dbpass); unless( defined $dbh ) { warn( "($$) Database connect failed: $DBI::errstr\n" ); } my @userids = (); my @passwords = (); my $sth = $dbh->prepare("SELECT id,userid,passwd FROM credentials"); $sth->execute(); while ( my @row = $sth->fetchrow_array ) { $userids[$row[0]] = $row[1]; $passwords[$row[0]] = $row[2]; } $sth->finish; # $dbh->disconnect opendir( DIR, '/usr/local/bin' ); my @filenames = readdir DIR; closedir DIR; my $userid; for( my $i=0; $i<=$#filenames; ++$i ) { $sth = $dbh->prepare("SELECT id FROM target WHERE note='$filenames +[$i]"); $sth->execute(); my @row = $sth->fetchrow_array; if( defined $row[0] ) { next; } open( FILE, '<', "$filenames[$i]" ); my $line = <FILE>; while( defined $line ) { if( $line =~ /ssh (\w+)\@([\d\.]+)/ ) { my $username = $1; my $ipaddr = $2; if( $username =~ /\$userid/ ) { $userid = 4; } else { $userid=0; for( my $j=0; $j<=$#userids; ++$j ) { if( $username =~ $userids[$j] ) { $userid = $j; last; } } if( $userid == 0 ) { warn "Unknown username encountered: $username\n"; } else { $sth = $dbh->prepare("INSERT INTO target (target,note,cred +,enapwd) VALUES ('$ipaddr','$filename[$i]',$userid,$userid)"); $sth->execute(); } } } } close FILE; } exit 0;
The error line is 60, the one beginning with "$sth = $dbh->prepare("INSERT INTO target...". I know this because if I comment out just this one line, it compiles without an error. Heres the output I get when I leave it in:
$ perl -c loader.pl Loading DB routines from perl5db.pl version 1.32 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. BEGIN not safe after errors--compilation aborted at /usr/share/perl5/C +arp/Heavy.pm line 11. Compilation failed in require at /usr/share/perl5/Carp.pm line 33.
Note that Carp is actually commented out at the top, so DBI is pulling it in. This is ultimately an issue with Carp.
Any aid identifying what is wrong here, also appreciated :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: No errors listed
by poj (Abbot) on Nov 09, 2014 at 17:29 UTC | |
|
Re^2: No errors listed
by RichardK (Parson) on Nov 09, 2014 at 17:30 UTC |