This question got me thinking how to do it in windows. Im not sure what platform you are using, but here is how I got it working on Win2000. I use the popular WinZip program to create the files. I first tried using something like system($cmd,"args") but could not get it to work.
Doing some searching, I found the Win32::Process module. This is my first attempt and a quick hack using this module but it is tested and working.
Winzip expects filenames to be passed with complete paths and quoted to support long file names: "c:\mypath\to\my\Cool Archive.zip"
#!/usr/bin/perl -w # Using WinZip to zip files up on Windows machine. use strict; use Win32; use Win32::Process; my $cmd = "C:\\Program Files\\WinZip\\winzip32.exe"; my $rootdir = "c:\\Documents and Settings\\bch\\My Documents"; my $filename = '"c:\\Documents and Settings\\bch\\My Documents\\te +starchive.zip"'; my @files = ('got milk.jpg','kellogs.jpg','gravity.jpg','Resume.do +c'); for my $x (0..(@files-1)) { $files[$x] = qq["$rootdir\\$files[$x]"]; } sub print_error() { return Win32::FormatMessage( Win32::GetLastError() ); } Win32::Process::Create(my $processobj, "$cmd", "winzip32 -min -a $filename @files", 0, DETACHED_PROCESS, ".") or print_error();
Help this helps!
zzspectrez
In reply to Re: Creating Zip files
by zzspectrez
in thread Creating Zip files
by Beelzebub
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |