Solved

dead-link detection

Posted on 1998-11-30
4
279 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
ID: 1829827
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
ID: 1829828
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
ID: 1829829
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
ID: 1829830
Thanks!!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo‚Ķ
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

772 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