in reply to LWP for URL monitoring - 500 connect timeout errors

Hi, Well, I've progressed some as you can see from this thread - but I've run into another issue, slightly different. How to deal with redirections. For example I've got the following website to monitor http://www.eserve.com.sa Which redirects to http://www1.elm.com.sa/Portal/Ar/Topics/Services/ However, for monitoring purposes I would like to monitor the first website as the rederiction can be changed. Now, following was my script:
# !C:\Perl\bin use strict; use warnings; use LWP::UserAgent; my $url = shift or die "URL expected\n"; my $useragent = LWP::UserAgent->new; $useragent->proxy(['http', 'ftp','https'], 'http://192.168.5.39:8080/' +); $useragent -> timeout( 20 ); my $request = HTTP::Request->new( HEAD => $url ); my $response = $useragent->request($request); print $response->status_line, "\n"; print $response->is_success, "\n"; print $useragent->proxy('http'),"\n";
And following is the response to ach of the abiove websites: C:\SCRIPTING>urltestv5.pl http://www.eserve.com.sa 400 Bad Request C:\SCRIPTING>urltestv5.pl http://www1.elm.com.sa/Portal/Ar/Topics/Services/ 200 OK Is there any way around this? Or if I can capture the redirection from the script itself and then do HEAD to that? Any ideas? Appreciate your support and assistance

Replies are listed 'Best First'.
Re^2: LWP for URL monitoring - 500 connect timeout errors
by Anonymous Monk on Jul 20, 2009 at 13:52 UTC
    That is weird, can you try
    # for window set http_proxy=http://192.168.5.39:8080/ # for linux export http_proxy=http://192.168.5.39:8080/ lwp-request -USe -m get https://www.eserve.com.sa/ lwp-request -USe -m head https://www.eserve.com.sa/
    and show the output
      So, is it an anomaly,
      C:\Perl\bin>lwp-request -Use -m get http://www.eserve.com.sa/ GET https://www.eserve.com.sa/ User-Agent: lwp-request/5.810 500 Connect failed: connect: Unknown error; Unknown error Content-Type: text/plain Client-Date: Tue, 21 Jul 2009 08:39:54 GMT Client-Warning: Internal response 500 Connect failed: connect: Unknown error; Unknown error C:\Perl\bin>lwp-request -Use -m head http://www.eserve.com.sa/ HEAD https://www.eserve.com.sa/ User-Agent: lwp-request/5.810 500 Connect failed: connect: Unknown error; Unknown error Content-Type: text/plain Client-Date: Tue, 21 Jul 2009 08:40:09 GMT Client-Warning: Internal response

      Don't know how to proceed from here. Or iwll I have to simply hardcode all the redirections?

        First you set the proxy variables , otherwise lwp-request can't connect