Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Google monitoring perl script errors, assistance appreciated

Status
Not open for further replies.

bulgin

IS-IT--Management
Mar 17, 2005
13
US
Hello, and thanks for letting me in!

Okay, I'me a pretty avid reader of the O'reilly series of Hack Books, but it seems that I've been coming across more and more errors in their perl scripts as I continue to read. I've attached below a perl script written by the author of "Linux Server Hacks" Rob Flickenger which claims to be able to output the sites users are googling. This is called Hack #60 on page 122 of that book. Writing to O'reilly has not brought a response, and neither has a polite inquiry to Mr. Flickenger. So I'm asking for help in this forum. This script has some kind of error on line 5 which produces the error:

regex compile: Unmatched ) or \)

What is very interesting is that this script works fine when I run it in the Xondros OS environment. However, when I run it in a Centros or Red Hat 9 distribution, I recieve the above error. So here is the script. If you examine line 5 perhaps you might find the error. If so, please let me know. Or, if the script is not at fault but rather dependencies or modules that interact with Perl... well, I'm a relatively newbie to perl so perhaps you can shed some light on this subject. I am running perl version:

5.8.0 with 1 registered patch.

Here is the interesting script:

#!/usr/bin/perl
use Socket;
$|++;

open(NG,"ngrep -lqi '(GET|POST).*/(search|find)' |");
print "Go ogle online.\n";
my ($go,$i) = 0;
my %host = ( );

while(<NG>) {

if(/^T (\d+\.\d+.\d+\.\d+):\d+ -> (\d+\.\d+\.\d+\.\d+):80/) {
$i = inet_aton($1);
$host{$1} ||= gethostbyaddr($i, AF_INET) || $1;
$i = inet_aton($2);
$host{$2} ||= gethostbyaddr($i, AF_INET) || $2;
print "$host{$1} -> $host{$2} : ";
$go = 1;
next;
}
if(/(q|p|query|for)=(.*)?(&|HTTP)/) {
next unless $go;
my $q = $2;
$q =~ s/(\+|&.*)/ /g;
$q =~ s/%(\w+)/chr(hex($1))/ge;
print "$q\n";
$go = 0;
}
}
 
no blatant errors in the perl code you posted, It seems like an OS issue, not a script issue. Maybe a query in the Linux forum would be helpful.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top