I dont see you doing any lwp action in this script, and i'm quite unsure why
CGI::ReadParse is used at all...
even tho this may make me a fish giver, i'd like you to concider the
following:

### SCRIPT ###
use strict;
use LWP::UserAgent

my $url = 'foo.bar.com/index.html';

### Set up the useragent ###
 my $ua = new LWP::UserAgent;
 $ua->agent( 'Mozilla/4.74 [en] (Win98; U)' );

### do the request, get the responce ###
 my $req = new HTTP::Request('GET', $url);
 my $res = $ua->request($req);

### print out the result, including the header and all that ###
print $res->as_string();

### END SCRIPT ###

i think the above script would largely do what you need....

hth,

Jos Boumans

> The code is exactly the same in both cases.  Here is more detail:
>
>
> use LWP::Simple;
> use CGI;
> CGI::ReadParse(*in);
>
> $q=new CGI; #invoke CGI object
> print $q->header('text/html');
>
> #unfix passed url to true url
> $url1 = $in{"site"};
> $url1 =~ s/----/\?/;
> $url1 =~ s/\*\*\*\*/&/g;
>
> #check for existence of Internet site by bringing back header
> #test only if not a forced read of backup
> if (!$in{"backit"}){
> $base_url=$url1;
> $test=head($base_url);
> }
>
> if ($test && !$in{"backit"}) {
> #website was found
> $topframe=0;
> $site=$url1; #use link to website
> } else {
> #website was not found
> $topframe=10;
> #find full name of archived file
> @types = qw(html pdf txt doc gif jpg xml shtml shtm asp htm);
> foreach $type (@types) {
> $arch_url = "http://xxx.cecinc.com/msdsSaved/backup/".$in{"id"}.".".$type;
> $test=head($arch_url);
> if ($test) {
> $site=$arch_url;
> if ($in{"backit"}) {
> $banner="forced.html" #if forced backup, display notice
> } else {
> $banner="warning.html" #if site wasn't found, display warning
> }
> last;
> }
> }
> }
>

> > I've written a program that checks for the existence of a website by
> > retrieving an HTTP header when fed a URL.  It works beautifully on my
> server
> > (NT running Windows '98) but locks when I installed it on my client's
> server
> > (NT running Windows 2000).  The important guts of the code are:

Reply via email to