Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

dead-link detection

Posted on 1998-11-30
4
Medium Priority
?
295 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
squimph earned 400 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

Give Your Engineering Team a Productivity Boost

Learn why container technology is so powerful and how it can provide your team with productivity gains and other benefits.

Question has a verified solution.

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

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
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.

670 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