
mohanprasad
Novice
Nov 6, 2008, 10:28 PM
Post #1 of 3
(837 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. #!/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; }
|