LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 12-08-2005, 06:48 AM   #1
irfanhab
Member
 
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
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,617

Rep: Reputation: 136Reputation: 136
Try (perl) :
Code:
#!/usr/bin/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>) {
    chomp;
    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.
 
  


Reply


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


All times are GMT -5. The time now is 05:03 PM.

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