2

As a part of my Perl script I have the following simple command which is supposed to download a $url and store its contents to a file $file:

getstore("$url", "$file");

This works perfectly fine when I run it on my fedora Linux, however when I run the same code on Windows, it seems that the $file remains empty..

This is very strange since, as I mentioned, there was no change to the code and this command is very basic.

Maybe anyone has a clue why such behavior might occur?

Thanks!

Eugene S
  • 6,709
  • 8
  • 57
  • 91
  • What are you using as the filename? – Nick Jan 25 '12 at 08:31
  • 1
    Are you checking the status returned by getstore? It looks like HTTP::Status is exported along with it so I think you should be able to store the code and then call status_message( $code ) – Nick Jan 25 '12 at 08:49
  • I tried the following: `my $status = getstore("$url", "$file"); print "$status\n";` As a result the status is `500`, though I am not sure what it means. – Eugene S Jan 25 '12 at 08:58
  • 500 is Internal Server Error. – choroba Jan 25 '12 at 09:00
  • What exactly is the URL you're testing with? – Nick Jan 25 '12 at 09:06
  • @choroba, Normally, yes, but LWP does use codes in the 500 block to indicate some client errors, possibly including file creation errors. I don't know if it uses 500 specifically, though. – ikegami Jan 25 '12 at 09:14
  • Again I would like to emphasize that the same code works fine on Linux fedora platform, however I am not sure that it has something to do with read/write permissions since I see(in sniffer) that no HTTP GET is being issued at all.. – Eugene S Jan 25 '12 at 09:27
  • Is your Windows machine behind a proxy by any chance? – Nick Jan 25 '12 at 10:21
  • Also, might it be worth using get rather than getstore while testing so that you can confirm whether the issue is with accessing the data or writing the file? – Nick Jan 25 '12 at 10:22
  • I am having the same problems with `LWP::Simple` on Windows, I get a 500 warning after a long timeout. It also seems to affect `ppm` from ActivePerl and the `cpan` installer, which I assume may be using this or similar modules. – TLP Jan 25 '12 at 11:01
  • 1
    @nick I think proxy is the culprit, but as my machine uses automatic detection, and I fail to find anything helpful on google, I've no idea how to find out how to get hold of the proxy server name. You have any idea? – TLP Jan 25 '12 at 11:40
  • 1
    Is it configured via a PAC file? – Nick Jan 25 '12 at 12:23
  • @Nick It's windows. I have no idea how it works. I am guessing DHCP has something to do with it. – TLP Jan 25 '12 at 16:17
  • @Nick I tried the same with simple "get" and it seems fine so I guess it's not an issue with proxy. I have no idea what is the problem to do the same with "getstore". Anyway I think I'm going to stick with "get" for now. Thanks! – Eugene S Jan 26 '12 at 08:59
  • if you do print $file does it look right? If you switched from something like /usr/file.txt to c:\user\file.txt then perl will see the \ as escapes so you need to either use "c:\\user\\file.txt" or 'c:\user\file.txt' – Dean MacGregor Feb 28 '13 at 20:15

1 Answers1

0

Finding a proxy quite easy sometimes:

Try to open a nonexisting webpage and most of time the PROXY reports an error and print out its own details.

Try this: -.ds.com Check the line: Your web proxy is:....

user1126070
  • 5,059
  • 1
  • 16
  • 15