hello,
i'm a newby and not very good at cgi/perl and i'v been trying for 2 day's now to get this script i found on the internet to work
this is the page of the scripts article:
http://www.devarticles.com/index.php?option=content&task=view&id=622
I only need the part where it get's the info files form the servers and then updates the database to work!
which is this part but cant get it to work:
#!/usr/bin/perl
my ($ip_date, $file_time, $file, $apnic, $ripe, $arin, $lacnic, @regis
+tries, $url, $curl);
$ip_date = (strftime("%Y%m", localtime(time)))."01";
$file_time = (strftime("%Y%m%d-%H%M", localtime(time)));
$file = $file_time."_ip_data.txt";
$apnic = "ftp://ftp.apnic.net/pub/stats/apnic/apnic-latest";
$ripe = "ftp://ftp.apnic.net/pub/stats/ripe-ncc/_ripencc.latest";
$arin = "ftp://ftp.apnic.net/pub/stats/arin/arin.".$ip_date;
$lacnic = "ftp://lacnic.net/pub/stats/lacnic/lacnic.".$ip_date;
open (BODY,">>$file");
@registries=($apnic,$ripe,$arin,$lacnic);
foreach $url(@registries)
{
# Init the curl session
$curl= WWW::Curl::easy->new() or die "curl init failed!\n";
$curl->setopt(CURLOPT_URL, $url);
$curl->setopt(CURLOPT_FTP_USE_EPSV, '0');
$curl->setopt(CURLOPT_FILE, *BODY);
if ($curl->perform() != 0)
{
print "Failed ::".$curl->errbuf."\n";
}
}
close BODY;
$dbh = DBI->connect("DBI:mysql:host=localhost;database="data_base","us
+er","pass",{PrintError=>0,RaiseError=>1});
$sth = $dbh->do("DELETE from ip_map");
print "\n\nData from ip_map table dropped\n\n";
$sth = $dbh->prepare("INSERT into ip_map values (?,?,?,?)");
$count = 0;
open (PROCESS, "<$file");
while ($line = <PROCESS>) {
chomp ($line);
if (($line =~ m/\|ipv4\|/) and ($line !~ m/\*/)) {
($registrar,$country_code,$item_type,$start_ip,$num_ip,$entry_date, $r
+egistry_type) = split(/\|/, $line);
@octets_start = split(/\./, $start_ip);
$long_start = 0;
foreach $octet_start (@octets_start) {
$long_start <<= 8;
$long_start |= $octet_start;
}
$long_end = $long_start + ($num_ip-1);
$count += $sth->execute($country_code,$registrar,$long_start,$long_end
+);
}
}
close PROCESS;
if i upload this script as a .cgi or .pl with chmod 755 and then call it in the browser nothing happens, no error's either.
am i missing a path to files or something?
do need to call this form shell?
curl is installed!
can some one please help me with this!!!!
thanx for your help
Janitored by holli - added code tags
Retitled by holli from 'PLEASE HELP'.