use Net::FTP;
$ftp = Net::FTP->new($host) or die "Cannot connect to $host: $@";
$ftp->binary;
$ftp->login($user, $pass) or die "Cannot login: ", $ftp->message;
$ftp->cwd("downloads") or die "Cannot change working directory to downloads: ", $ftp->message;
@ls = $ftp->ls;
if (@ls)
{
$ftp->get($ls[0]) or warn "Cannot get $ls[0]: ", $ftp->message;
$ftp->delete($ls[0]) or warn "Cannot delete $ls[0]: ", $ftp->message;;
}
$ftp->quit;
When I run the above code which connects to an FTP server of a remote host, it tries to get a PDF file in the downloads
directory, but the PDF file transferred is 8 bytes less in size than the original file, so it doesn't open properly in a PDF reader.
Is there something I am not doing correctly? The FTP server is vsftpd on Ubuntu.