Guest User

Untitled

a guest
Aug 15th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. How can I download directories and files from an FTP server using Perl?
  2. use Net::FTP;
  3. use Net::FTP::File;
  4.  
  5. my $ftp=Net::FTP->new("hostname");
  6. $ftp->login("username","password");
  7. $ftp->cwd("/repository_name");
  8. my @ftp_lists=$ftp->ls("/repository_name ");
  9.  
  10. foreach my $ftp_file(@ftp_lists){
  11. push @ftp_dirs, $ftp_file if($ftp->isdir($ftp_file));
  12. push @ftp_files, $ftp_file if($ftp->isfile($ftp_file));
  13. }
  14.  
  15. my $username = "tim";
  16. my $password = "asdfghj";
  17. my $domain = "example.com";
  18. my $get = `wget -P /var/www/$domain/ -m ftp://$username:$password@$domain/httpdocs`;
  19. my $mv = `mv /var/www/$domain/httpdocs/* ../`;
  20. my $del = `rm /var/www/$domain/httpdocs/`;
Add Comment
Please, Sign In to add comment