I'm new to using LWP.  I have developed a Perl script that checks takes an
incoming URL, uses the LWP head() command to check to make sure that the
webpage exists, and then writes a frameset depending upon whether or not it
found the webpage (displays the page if it exists, a saved file from the
server if it doesn't).  The code is at the end of this message.

The routine works without a hitch in my office, running Activestate Perl 5
on a Windows NT server.  However, I put the identical code for a client on
their server, and it hangs up on the head() line.  That is a Windows 2000
machine, running Activestate Perl 5.6.0.620.  I'm stumped.  Everything else
I've installed runs fine for that client runs fine.  I'm sure it's not a
problem with path references.  Any thoughts?

Here's the code.  $in{"backit"} and $in{"site"} are parameters passed by the
referring page:

use LWP::Simple;
use CGI;
CGI::ReadParse(*in);

$q=new CGI;     #invoke CGI object
print $q->header('text/html');

#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://www.anycompany.com/Saved/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;
                }
        }
}

#generate frameset to display results
if ($topframe==0) {
        #website found. no warning to be displayed.  generate one frame
        print <<EOF;
        <FRAMESET  ROWS="100%">
            <FRAME NAME="msds_data" SRC="$site" MARGINWIDTH="1" MARGINHEIGHT="1"
SCROLLING="auto"
                FRAMEBORDER="0">
        </FRAMESET>
EOF
;
} else {
        #website not used.  display archive in one frame, warning in another
        print <<EOF;
        <FRAMESET  ROWS="10%,*">
            <FRAME NAME="warning" SRC="$banner" MARGINWIDTH="10" MARGINHEIGHT="10"
SCROLLING="no"
        FRAMEBORDER="0" NORESIZE>
    <FRAME NAME="msds_data" SRC="$site" MARGINWIDTH="1" MARGINHEIGHT="1"
SCROLLING="auto"
        FRAMEBORDER="0">
        </FRAMESET>
EOF
;
}


- Deb Thompson
Civil & Environmental Consultants
800-365-2324
www.cecinc.com


Tracking #: 1C9558E53A66D511954700508BC28C5A4F227837

Reply via email to