hola como estas quisiera saber si me puedes ayudar con este programa que trae el ntop; lo que hace es llenar la base de datos pero hay una funcion que no me deja pasar a la siguiente linea bueno aqui dejo el programa se corre con perl. la linea es recv(), no me la reconoce, en realidad no se si me falta declarar algo,por favor ayudame please. El programa se llama mySQLserver.pl lo puedes buscar por internet por si acaso me eqivoque en algo. gracias y que diosito este iluminandote
#!/usr/bin/perl
# This is a sample program written in Perl that does the same thing as the
# java program ODBCServer.java
#
# This program needs DBI and DBD installed to works
#
# Author: Daniel Savard <
[email protected]>
#
use DBI;
use IO::Socket;
use Sys::Hostname;
# Main program
my $buffer = " ";
my $bufLength = 1514;
my $DBDServer = "DBI:mysql:NTOP";
my $socket = null;
my $rv;
# Listen to the udp port
$socket = IO::Socket::INET->new(LocalAddr => 'localhost',
LocalPort => 4000,
Proto => 'udp',
Type => SOCK_DGRAM);
# Open the database connection
my $dbh = DBI->connect('DBI:mysql:NTOP', 'NTOP', 'NTOP') or die "Couldn't conne$ DBI->errstr;
# Infinite loop
while(1) {
# Receive the SQL statement
recv($socket, $buffer, $bufLength, 0) || die "recv: $!";
# Print the SQL statement
print "$buffer\n";
# Correct the SQL if needed
$buffer =~ s/^DELETE \*/DELETE/; # Change 'DELETE *' for 'DELETE'
# Correct dates, not needed if ntop gives us yyyy-mm-dd, ntop up
# to 1.2a12 gives mm/dd/yy . 06.02.00 Ralf Amandi
# @dates= ($buffer =~ m!'../../.. ..:..:..'!g);
# foreach $date (@dates) {
# # mm/dd/yy -> yy-mm-dd
# @items=split("[/ ']",$date,6);
# $new="'$items[3]-$items[1]-$items[2] $items[4]'";
# $buffer =~ s/$date/$new/g;
# }
# Correct insert into host (in the mdb database the default
# for FirstSeen is set to now(). mySQL can not handle this). 06.02.00 Ralf Aman
if (substr($buffer,0,59) eq 'INSERT INTO Hosts (IPaddress, MACaddress, NICven$ $buffer='INSERT INTO Hosts (IPaddress, MACaddress, NICvendor, FirstSeen) $ }
# Execute the SQL statement
$rv = $dbh -> do($buffer);
# Print a blank line
print "\n";
}