Check CPAN module Archive::Zip and other related modules.
Another way to get the anwser for this question, is to go to www.cpan.org, do a module search by key word "zip". It will give you the answer you want.
Once you get to the document of the module, you will see a big FAQ list, don't bother it for now. To make it simple, and get yourself started right the way, go straight to those two sections: "how to add a directory/tree to a zip" and "how to extract a directory/tree".
| [reply] |
If I understand correctly, you are looking for something similar to a release distribution process. You are sending files via FTP to each client machine from your server, and you want to know how to kick off the unzip remotely on the client machines from the server (or within FTP).
Well, to start with, you can't kick off unzip remotely within an FTP session, for obvious security reasons.
There are a lot of commercial (and free?) products to do remote package/zip releases (such as OnCommand). You will have to do a bit of research on this.
Or you can write your own Windows service on each of the client to unzip any FTP files in certain predefined directories after they arrive. But that could be a complicated task if you want to do it properly. You need to introduce trigger files with CRC to make sure the FTP is complete, and to be efficient, you probably need to use the system filewatcher instead of a periodic poller.
If I was to implement the solution, I won't bother with remote processes because they are complicated and not worth the effort. If your data files are not big, you could just write a simple FTP program that runs on your server, and sends all the data files to each of the clients in a list. The following is an outline of the algorithm:
my @clients;
my @files_to_send;
foreach my $client(@clients) {
my $c = create_FTP_connection($client);
foreach my $file(@files_to_send) {
$c->Put($file);
}
close_FTP_connection($c);
}
Update: If you already has the FTP scripts on the clients, then you simply need to do a system($PATH_TO_WINZIP, "filename.zip"); or something alike to extract the zip file. You need to check the Winzip manual to find out the correct parameters to use.
| [reply] [d/l] [select] |
| [reply] |
Here's a simple subroutine I use to unzip the contents of a zip file. It's just the basics, but you could do a lot more using the CPAN docs
#! c:\perl\bin\perl.exe
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
use strict;
my ($zipfl, $zippath);
print "Enter the name of the zip file: \n";
chomp ($zipfl = <stdin>);
print "Enter the absolute path where the contents are to be blown up!:
+ \n";
chomp ($zippath = <stdin>);
extract_tree("$zipfl","$zippath");
sub extract_tree($$)
{
my $source=shift;
my $target=shift;
chomp ($target);
my $zip = Archive::Zip->new();
$zip->read("$source");
$zip->extractTree( "", "$target" );
}
| [reply] [d/l] |