Advertisement
Guest User

Untitled

a guest
Apr 30th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use Net::FTP;
  5.  
  6. my $ftp_site = '193.54.74.20';
  7. my $ftp_dir = '/';
  8. my $ftp_user = 'anonymous';
  9. my $ftp_password = 'a_password';
  10. my $glob = '-la *';
  11. my @remote_files;
  12.  
  13. my $ftp = Net::FTP->new($ftp_site)
  14. or die "Could not connect to $ftp_site: $!";
  15.  
  16. $ftp->login($ftp_user, $ftp_password)
  17. or die "Could not login to $ftp_site with user $ftp_user: $!";
  18.  
  19. $ftp->cwd($ftp_dir)
  20. or die "Could not change remote working " .
  21. "directory to $ftp_dir on $ftp_site";
  22. print "Saw:";
  23. @remote_files = $ftp->ls($glob);
  24.  
  25. foreach my $file (@remote_files) {
  26. print "Saw: $file\n";
  27. }
  28.  
  29. $ftp->quit();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement