1

I'm using Padre as my IDE with Strawberry Perl on Windows 7 Pro.

I'm trying to create a perl script that goes to a text file on a website, and then reads/copies the text file.

But I can't get LWP to work even for the simplest LWP command ever.

#!/usr/bin/perl
   use strict;
   use warnings;
   use LWP::Simple;

   getprint('http://www.perlmeme.org') or die 'Unable to get page';

   exit 0;

I keep getting this error message: 500 can't connect to proxy.sn.no:8001 (Bad hostname) eg 500 can't connect to (Bad hostname) http://www.perlmeme.org

I've been googling around, used Microsoft Fixit to reset ports, etc but I still can't make it work. http//www.justskins.com/forums/lwp-connect-failing-bad-119421.html

Can anyone help me out here? Been stuck for many hours :(

Edit:

--1 foreach my $key (keys %ENV) { print "$key: $ENV{$key}\n" if $key =~ m/proxy/i; }

Yes it prints out FTP_PROXY and HTTP_PROXY both followed by this: http://proxy.sn.no:8001/

That's the proxy that I got from this helpthread How do I install a module? Strawberry Perl issues

I had the proxy problem, then I tried the config from that thread, then the proxy problem was still there.

--2 I'm not expecting any proxy to be used on my end or anything. Just wanna connect the perl script to the website to retrieve a text document.

--3 ping had 0% loss. (I can only post two hyperlinks in this post)

--4 I'm using Windows.

Community
  • 1
  • 1
John Tan
  • 509
  • 3
  • 8
  • 19
  • 1
    Does `foreach my $key (keys %ENV) { print "$key: $ENV{$key}\n" if $key =~ m/proxy/i; }` print anything? (I ask because `LWP::Simple` is documented to take its proxy settings from environment variables named things like `*_proxy`.) – ruakh Dec 21 '11 at 23:51
  • 4
    Are you expecting a proxy to be used on your end? It's not clear whether your problem is that you're using a proxy you shouldn't be using or it's that you're having problems connecting to the proxy you should be using. – ikegami Dec 22 '11 at 00:43
  • Try `ping www.perlmeme.org` to see if you can even connect to that server. – Brad Gilbert Dec 22 '11 at 01:39

1 Answers1

1

LWP will honor the http_proxy environment variable and try to use it as an HTTP proxy. Check with env | grep http_proxy on Unix.

Schwern
  • 153,029
  • 25
  • 195
  • 336
  • 3
    @JohnTan You are using a proxy, and it is broken. Turn it off. If you're stuck behind a firewall, find a new proxy or talk to your firewall administrator to allow the connection you need. – Schwern Dec 22 '11 at 12:14
  • How do I turn off the proxy? I'm using ZoneAlarm firewall but I've already closed it from the taskbar (the area near the volume). I am the only user of this computer. – John Tan Dec 22 '11 at 13:52
  • Unset the HTTP_PROXY and FTP_PROXY environment variables! – reinierpost Dec 22 '11 at 13:54
  • I entered unset http_proxy into the cmd line and I had this error message: 'unset' is not recognized as an internal or external command, operable program or batch file. – John Tan Dec 22 '11 at 19:51
  • @JohnTan I don't know much about managing environment variables on Windows. You'll have to do some Googling and reading or maybe ask a question on superuser.com. http://support.microsoft.com/kb/310519 is a start. – Schwern Dec 22 '11 at 22:55