[ic] LWP::Simple get url returns error

Peter peter at pajamian.dhs.org
Thu May 12 17:07:02 EDT 2005


On 05/12/2005 06:51 AM, daniel castro wrote:
> 
> Hi list I am getting this:
> 
> 157.253.41.51 DeTQgeo3:157.253.41.51 - [12/May/2005:12:46:15 +0000] 
> plcost /cgi-bin/plcost/test.html Runtime error: Couldn't get 
> http://www.larepublica.com.co/inc/imagenes/indicad.php?env=7m9r5j5c at 
> (tag 'exchange_rate') line 8.

LWP::Simple is It doesn't give you any useful info if it fails.  Use 
LWP::UserAgent instead.

> And a error 500 in the page I call the user tag.

That's because you're using die in your usertag.  Use ::logError and 
then return 0 instead.

> My usertag is this one:
> UserTag exchange-rate Order currency
> UserTag exchange-rate PosNumber 1
> UserTag exchange-rate Routine <<EOR
> sub {
> 
> my ($currency) = @_;

This is the only place where curency is even used?  You realise that 
someone could pass "Frank's value coupons" for the currency and get the 
same exchange rate?

> my $url;
> $url = 
> 'http://www.larepublica.com.co/inc/imagenes/indicad.php?env=7m9r5j5c';

env= looks like a session key.  That URL is likely to only work for the 
browsing session you got it from, but you'd probably get a better idea 
of what the problem is if you use LWP::UserAgent and look at the error 
messages returned.

> use LWP::Simple;
> my $content = get $url;
> die "Couldn't get $url" unless defined $content;
> $content =~ /(\d\.\d{2,5})(.........)/;

RegExp is too generic.  If you get an errordocument back your tag will 
return the remote server version (or something else) as the exchange rate.

> return $1;
> exit;

Never use exit or die in a tag, they will cause Interchange to stop 
running and return a 500 error (I think, but I'm sure it won't do good 
things).  In this particular case exit is never reached so it won't hurt 
anything, but it's also an extra line that doesn't do anything.  exit 
and die won't just cause your usertag to exit.  They will cuase 
interchange itself to exit rather ungracefully.

> }
> EOR
> 
> 
> i am trying to get the exchange rate for the colombian peso.
> 
> With rsDVD in the IRC chat came to the conclusion that interchange is 
> unable to resolve a host, so he gest lost and retunr the error. but we 
> are not sure.

How did he come to that conclusion?  From what you've shown here that 
*might* be the problem, but then the problem could be just about anything.

Peter


More information about the interchange-users mailing list