#!/usr/bin/perl # Program to recursively put a directory on to an FTP server # after unzipping a Zip file. use strict; use warnings; use Net::FTP::Recursive; use Archive::Zip; # FTP host server my $host = 'myhost.mydomain.com'; my $zip_file_to_put = 'ABC.zip'; # Get the zip archive. my $zip_file_obj = Archive::Zip->new($zip_file_to_put) or die("Could not get zip file: $!"); # Extract the zip files. $zip_file_obj->extractTree(); chdir('ABC') or die("Could not change directory: $!"); # my $current_dir = `pwd`; # print $current_dir, "\n"; my $ftp_obj = Net::FTP::Recursive->new($host, Passive => 1) or die "Cannot connect to $host: $!" ; # Log in to the FTP server. $ftp_obj->login('username', 'password') or die "Cannot log in to $host: $!" , $ftp_obj->message(); # Go into binary mode for the transfer my $type = $ftp_obj->binary(); # Put the directory in a recursive fashion. my $output = $ftp_obj->rput(); # Print the error messages if the recursive put failed. if($output) { print qq; } # Quit! $ftp_obj->quit();