> I have a perl script that FTPs a file down from another server
[snip]
> I am not sure HOW to do the file size check.
I wrote the following using the LWP::Simple module:
print "beginning download of ", ftp_file_size( $ftp_path_gz ), "\n";
$status = download_file( $ftp_path_gz, $local_path_gz );
sub ftp_file_size
{
my ( $url ) = @_;
my @info = head( $url );
if( scalar @info == 0 )
{
return 'unknown size';
}
return sprintf( "$info[1] bytes (%.2f MB)", $info[1]/(1024*1024) );
}
sub download_file
{
my ( $file_to_ftp, $save_filename ) = @_;
my $status = getstore( $file_to_ftp, $save_filename );
if( $status == 200 )
{
print "Download successful.\n";
return 1;
}
else
{
print "An error occurred during the download.\n";
return 0;
}
}
> Do you want to do the file check locally or remotely? If local,
>
> perldoc -f stat
> (field 7)
>
> If remotely, Net::FTP provides the 'size' method. You definitely want
> to use Net::FTP for the FTP handling.
Your response seemed pretty adamant about using Net::FTP. Would I be better
off using that module instead of LWP::Simple for this? If so, why?
Thanks,
Bob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>