Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Can't connect" error using LWP and HTTP::Request

Status
Not open for further replies.

manjoufna

Programmer
Sep 7, 2001
9
0
0
US
Hello,

I'm trying to use a GET request via LWP:UserAgent and I'm getting a "Can't connect" error. I also get a "URL must be absolute" error depending on whether I hard-code the URL:

### This produces "400 URL must be absolute" error
my $response = $ua->get('$url');

### This produces "500 (Internal Server Error) Can't connect to (Timeout)" error
my $response = $ua->get('
Now when I use this code trying to connect to another unix machine within our company (the url is different, of course)I have no problems.

This all started because I'm trying to use the YahooQuote.pm, but I'm getting this 400 error. Is there supposed to be some unix admin config setup somewhere?

Here is my full perl code I'm trying to execute:
use LWP::UserAgent;
use LWP::Simple;
use HTTP::Request::Common;
$ua = LWP::UserAgent->new;
$ua->timeout($TIMEOUT) if defined $TIMEOUT;
$ua->env_proxy();
$url = 'print "url = $url ";
my $response = $ua->get('$url');
my $marg = $response->status_line;
print "$marg ";



Thanks for any help,
Margaret
 
Your get is wrong you have :

my $response = $ua->get('$url');
change it to

my $response = $ua->get($url);
or
my $response = $ua->get("$url");

Perl does not interpetolate variables that are encased in single quotes. You are literally sending '$url' to LWP. It doesnt like that.

 
Thanks for the tip about the single quotes. Now I can't get past the 500 Can't Connect error. If anyone knows how resolve this...

Thanks,
Margaret
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top