What do you mean secure environment? Does that mean you are behind a firewall on a secure intranet?, or using https?, or do you need to setup the secure channel yourself?
If you know where the file is on the remote filesystem, and can use ssh, Net::SSH2 might be useful, and it has a builtin sftp command, so your file is encrypted over the network. Google has many Perl ssh examples free for a search.
If you are going over a web browser, you can use Mechanize as mentioned above, or if the link is known, you probably can use the simpler LWP::Simple, and here is a generic example that includes any html auth you might need.
#!/usr/bin/perl -w #adapted from lwpcook use strict; use LWP::UserAgent; my $user = 'mini_me'; my $pass = 'foobar'; my $ua = LWP::UserAgent->new; my $URL = 'https://your_target_site.com/CSV/latest.csv'; my $filename = substr( $URL, rindex( $URL, "/" ) + 1 ); #print "$filename\n"; open( IN, ">$filename" ) or die $!; print "Fetching $URL\n"; my $expected_length; my $bytes_received = 0; my $req = HTTP::Request->new(GET => $URL); $req->authorization_basic($user, $pass); my $res = $ua->request($req, sub { my ( $chunk, $res ) = @_; $bytes_received += length($chunk); unless ( defined $expected_length ) { $expected_length = $res->content_length || 0; } if ($expected_length) { printf STDERR "%d%% - ", 100 * $bytes_received / $expected +_length; } print STDERR "$bytes_received bytes received\n"; # XXX Should really do something with the chunk itself print IN $chunk; } ); print $res->status_line, "\n"; close IN; exit;
In reply to Re: Reports Downloading
by zentara
in thread Reports Downloading
by aartist
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |