For Programmers: Free Programming Magazines  


Home > Archive > PERL Programming > September 2005 > CGI perlscript that downloads a URL file









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author CGI perlscript that downloads a URL file
Bluey

2005-08-31, 7:55 am

Hello!

I have a question about a CGI perl script.

I have a form that i fill a http file reference into.

Then I want the perl CGI program to pick up the URL and download the
file into a local path thats on the server.

I got everything right except for the part that downloads the URL file
to the local server path.

Can anyone please help me?

Best regards

Bluey

Paul Lalli

2005-08-31, 7:55 am

Bluey wrote:
> Hello!
>
> I have a question about a CGI perl script.
>
> I have a form that i fill a http file reference into.
>
> Then I want the perl CGI program to pick up the URL and download the
> file into a local path thats on the server.
>
> I got everything right except for the part that downloads the URL file
> to the local server path.
>
> Can anyone please help me?


Take a look at the LWP::Simple module, available on CPAN:
http://search.cpan.org/~gaas/libwww...b/LWP/Simple.pm

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

my $url = 'http://www.google.com/';
my $filename = 'google.txt';

my $response = getstore($url, $filename);
if ($response != 200) {
print "Error downloading, error code: $response\n";
}

__END__


Paul Lalli

Bluey

2005-09-01, 7:56 am

Thank you very much, Paul!

I worked very well!

Best Regards

Bluey

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com