... so I had to wrap the perl script in a bash script and it works (I
get the username in the access.log coming from mysql):
#####################################
#!/bin/bash
while read ip; do
/usr/local/bin/weblogin_getuser.pl $ip
done
#####################################
#!/usr/bin/perl
use warnings;
use strict;
use DBI;
$_=1;
my $db = DBI->connect("DBI:mysql:proxy", "proxy", "proxy");
my $query = $db->prepare('SELECT login FROM loginip WHERE ip = ?;');
my $ip = shift;
chomp $ip;
if ($ip !~ m/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) {
print "ERR user=nobody\n";
exit;
}
$query->execute($ip);
my ($login) = $query->fetchrow_array();
if ($login) {
print "OK user=$login\n";
} else {
print "ERR user=nobody\n";
}
$query->finish();
$db->disconnect();
###########################################
Unfortunately this makes the perl script connect/disconnect to mysql
every time. (I had the connect and prepare outside the while(<>)
loop).
So in a ugly way, it is working now, but I'd be thankful if someone
can shed some light on the problem.
Thanks,
Joao S Veiga
Received on Mon Oct 26 2009 - 13:16:00 MDT
This archive was generated by hypermail 2.2.0 : Mon Oct 26 2009 - 12:00:02 MDT