Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 12-08-2005, 06:48 AM   #1
Registered: Jan 2004
Location: Pakistan
Distribution: OpenSuse 10.2, Slackware 11, Solaris 10
Posts: 415

Rep: Reputation: 34
Resolving URL script

I have a list of URL's, I want to know which ones are valid, can someone write me a simple script in python or perl, which could tell me which sites are working (properly resolving) and which are not?
Old 12-08-2005, 08:38 AM   #2
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 5,473

Rep: Reputation: 420Reputation: 420Reputation: 420Reputation: 420Reputation: 420
Try (perl) :

use Socket;

# file where URLs are stored
my $file = '/path/to/url_file';

open URLS, "< $file" or die "Could not open $file: $!\n";

while (<URLS>) {
    next if /^$/;   # no need to test a blank line
    my $url = $_;
    s/http:\/\///;  # remove http:// from domaine name
    s/\/.*//;       # remove last / and URL path  if any

    if(gethostbyname $_) {
        print "$url is working\n";
    } else {
        print "$url is not working\n";

close URLS;

Last edited by keefaz; 12-08-2005 at 08:56 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ERROR The requested URL could not be retrieved While trying to retrieve the URL: /re Niceman2005 Linux - General 1 06-29-2005 10:51 AM
Use PHP URL processor script with Apache remi Linux - Networking 0 07-18-2004 02:44 PM
/etc/hosts resolving before DNS resolving ? markraem Linux - Networking 4 11-02-2003 05:54 AM
resolving host... soko Linux - Newbie 10 07-07-2002 11:50 AM
Resolving conflicts? Kage Linux - Software 0 01-27-2002 10:04 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:46 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration