CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
http file download

 



mohanprasad
Novice

Nov 6, 2008, 10:28 PM

Post #1 of 3 (889 views)
http file download Can't Post

Hello,
I have written this code to make a file local before start working on it.
But when i execute it is not copying the file to local. I am getting 401 error.
could you please let me know whats wrong with this code.
thaks in advance.


Code
   

#!/usr/bin/perl -w
use LWP::Simple;

my $filename = "http://sample.com/secure/sample.xls";

MakeFileLocal($filename);

sub MakeFileLocal {
my $filename = shift;

chomp($filename);

$filename =~ m/.*\.(.*)$/;
my $suffix = $1;
print "Suffix : $suffix\n";
my $newname = "d:/test/mohan/temp.$suffix";

unlink("$newname");

if ($filename =~ m/^http/i) {
print "Name matches starts with http://\n";
my $retval = getstore($filename, $newname);
die "Could not store it!!\n" unless is_success($retval);
} else {
my $cmd = qq~copy "$filename" "$newname"~;
print "$cmd\n";
my @a = `$cmd`;
}

if (-e "$newname") {
return $newname;
}

return 0;
}



KevinR
Veteran


Nov 7, 2008, 2:58 PM

Post #2 of 3 (872 views)
Re: [mohanprasad] http file download [In reply to] Can't Post

His code is good. I already helped him on another forum and the problem is the server he is using, not the perl code.
-------------------------------------------------


FishMonger
Veteran / Moderator

Nov 8, 2008, 7:34 AM

Post #3 of 3 (857 views)
Re: [KevinR] http file download [In reply to] Can't Post

However, there are problems with the script that are unrelated to the error in question.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives