Hi Sam,
A link from my website to another website. An example is http://www.maverick.local/
I know how to do a redirect btw. I'm hoping someone has an example for logging the link access to a database.
--Maverick
Main Topics
Browse All TopicsHi,
I'm trying to find a script(preferably perl) that can track an outbound link and write the data to a MySQL DB.
Can anyone point me to any examples or starting points?
--Maverick
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi Sam,
A link from my website to another website. An example is http://www.maverick.local/
I know how to do a redirect btw. I'm hoping someone has an example for logging the link access to a database.
--Maverick
when I need to do this I do something like
redirect.cgi?http://www.ma
my redirect cgi is :
#!/usr/bin/perl
$where2=$ENV{QUERY_STRING}
open(LOG,"">logFile");
print LOG <<EOT;
we transfered to: $where2
EOT
close(LOG);
print <<EOT;
Status: 302 re-direct
Location: $where2
EOT
exit;
OK.
This should do the trick. I assume that
- Your user-id is xxx
- Your password is yyy
- You created a database called xxx_logging
- You went into mysql and created a table in that database with a statement such as:
use xxx_logging;
create table logging (url text);
Use this script to log the URL and then redirect to it (replace xxx and yyy)
#!/usr/bin/perl
use CGI;
my $cgi = new CGI;
my $url = $cgi->param('url');
use DBI;
my $dbh = DBI->connect("DBI:mysql:xx
my $stmt = "insert into log_table (url) values ('$url');";
my $sth = $dbh->prepare($stmt);
$sth->execute() or die "Cannot execute $stmt";
print $cgi->redirect($url);
Now in practice I would create a different user-id for the database than your actual UNIX ID since you don't want to embed that in a script.
Business Accounts
Answer for Membership
by: elsammanPosted on 2003-11-07 at 08:00:16ID: 9702015
Sorry but what do you mean by an 'outbound link'?
...Sam