ghouse has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am using perl 5.6.1. I am getting "500 can't connect to server" error in the following code
#!/opt/perl-5.6.1/bin/perl my $ua = new LWP::UserAgent; $ua->timeout(12000); $ua->proxy('http','http://webproxy.ll.com:80'); my $res = $ua1->request(POST $REQurl, Content_Type => 'multipart/form-data', Content => [ file => [$ReqsDir] ]);
This error occurs only when I run the perl script in debug mode else it works ok i.e able to connect to the server This error occurs with/without a proxy Not sure what's wrong here.

Replies are listed 'Best First'.
Re: 500 Error
by glasswalk3r (Friar) on Feb 06, 2006 at 15:10 UTC

    The 500 error occurs in the server side. Probably, when running in debug mode, you forgot to add some additional parameter to the request that is made to the server. Of course, the application that runs in the server looks like fails miserably without giving a better explain of that is happening.

    Instead of running in debug mode, you may want to use Data::Dumper to checkout what your LWP script is doing.

    Alceu Rodrigues de Freitas Junior
    ---------------------------------
    "You have enemies? Good. That means you've stood up for something, sometime in your life." - Sir Winston Churchill
Re: 500 Error
by vishi83 (Pilgrim) on Feb 06, 2006 at 13:08 UTC

    Hi man !!
    I'm not clear of wat u want to know.. First be clear with your requirement.
    Learn more on LWP before proceeding with your code...

    The below code will extract the source code of the url passed.....


    use strict; use LWP::UserAgent; use Data::Dumper; my $url="http://10.x.x.x/login.pl"; my $ua = new LWP::UserAgent; my $request = new HTTP::Request POST => $url; $request->content_type('text/xml'); my $page = $ua->request($request); if ($page->is_success) { print $page->content; } else { print $page->error_as_HTML; }

    You can change $url as per ur requirement...

    I think your code is not tested... Make sure you give the correct domain name ( server ).



    Thank u

    A perl Script without 'strict' is like a House without Roof; Both are not Safe;
Re: 500 Error
by spiritway (Vicar) on Feb 07, 2006 at 00:51 UTC

    FWIW, 500 is "Internal Server Error", which could mean that the server itself has a problem. Debug mode might be sending it something to make it choke and dies.