Solved

dead-link detection

Posted on 1998-11-30
4
274 Views
Last Modified: 2013-12-25
I need a perl script to detect a dead-link
something like this:
            deadLink( URL )
deadLink() returns true if link exists, false otherwise.

anyone?
0
Comment
Question by:shlomoy
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
squimph earned 100 total points
Comment Utility
You can use the modules in the libwww package (http://www.perl.com/CPAN-local/modules/by-module/LWP/) to test a URL:

For example, call the following from the command line with the URL you want to test as the parameter:

#!/usr/bin/perl
$URL = $ARGV[0];
use LWP::UserAgent;
$ag = new LWP::UserAgent;
$ag->agent("CustomLinkChecker/1.0" . $ag->agent);
$req = new HTTP::Request GET => $URL;
$results = $ag->request($req);
if ( $results->is_success ) {
    print "URL exists.\n"

} else {
    print "Bad URL\n";
}
0
 
LVL 8

Author Comment

by:shlomoy
Comment Utility
from: http://www.perl.com/CPAN-local/modules/by-module/LWP/libwww-perl-5.41.readme
---begin quote---
If you want to install a private copy of libwww-perl in your home
directory, then you should try to produce the initial Makefile with
something like this command:

  perl Makefile.PL LIB=~/perl

The Makefile.PL program will start out by checking your perl
installation for a few packages that are recommended to be installed
together with libwww-perl.
----end quote----

where can I obtain this makefile?
0
 
LVL 1

Expert Comment

by:squimph
Comment Utility
Well, installing libwww-perl is a separate question but here goes...

First consider talking to your system administrator to ask that they install libwww in the central perl directory so everyone on the system can use it (most web servers already have it installed... I assume you've already checked)

If the admin refuses to install it, the instructions you have above will do it... 'perl Makefile.PL LIB=~/perl' will create a file called 'Makefile' ... then type 'make' and 'make install' to install the package.
0
 
LVL 8

Author Comment

by:shlomoy
Comment Utility
Thanks!!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now