Advertisement
Guest User

Untitled

a guest
Jun 5th, 2017
524
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.24 KB | None | 0 0
  1. #Fuh-zz <fuzzylunkinz@gmail.com>
  2. # Send files to egretfiles FTP as a mirror
  3. #  Waits for remote completion notification
  4.  
  5. use strict;
  6. use Getopt::Long;
  7. use Net::FTP;
  8. use Digest::MD5;
  9.  
  10. my $server = "ftp.egretfiles.com";
  11. my $user = "alleg@egretfiles.com";
  12.  
  13. open(PASS,"C:\\egretfiles.passwd");
  14. my $pass = <PASS>;
  15. close PASS;
  16.  
  17. my $local = "";
  18. GetOptions("b=s" => \$build, "r=s" => \$revision, "v=s" => \$version);
  19. if($version == "1.1")
  20.     $local = "C:\\inetpub\\wwwroot\\build\\AllegR6PDB_b$build_r$revision.exe";
  21. else if($version == "1.0")
  22.     $local = "C:\\inetpub\\wwwroot\\build\\AllegPDB_b$build_r$revision.exe";
  23. else
  24.     die "No version specified! Command line switch '-v' either 1.1 or 1.0";
  25.  
  26. print "Uploading files to $server\n";
  27. open(FILE, $local) or die "Can't open '$local': $!";
  28. binmode(FILE);
  29. my $hash = Digest::MD5->new->addfile(*FILE)->hexdigest;
  30. close FILE;
  31. my $size= (stat($local))[7];
  32.  
  33. my $ftp = Net::FTP->new($server, Debug => 0, Port => 21, Passive => 1)
  34.     or die "Cannot connect to '$server' $@";
  35.  
  36. $ftp->login($user,$pass)
  37.     or die "Cannot login ", $ftp->message;
  38. $ftp->put($local)
  39.     or die "Put failed ", $ftp->message;    
  40.  
  41. print "Files uploaded OK\n";
  42. $ftp->quit();
  43.  
  44. print "$local - hash: $hash size: $size\n";
  45.  
  46. exit 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement