Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

How to handle password protected zipfiles

by Anonymous Monk
on Dec 01, 2004 at 13:01 UTC ( #411439=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello Everyone.... I need some assistance/direction. I am looking for examples of how to handle zip files which are password protected. From what I can see, the existing "Archive" modules do not handle passwords for such instances. Any assitiance is greatly appreciated.. Cheers
  • Comment on How to handle password protected zipfiles

Replies are listed 'Best First'.
Re: How to handle password protected zipfiles
by nimdokk (Vicar) on Dec 01, 2004 at 13:21 UTC
    I have a homegrown solution that simply calls the commandline version of PKware's PKZIP program to unzip files with passwords and such. Something like:

    use File::Spec; $pkzip=File::Spec->catfile('path','to','pkzipc.exe'); qx!$pkzip -extract -pass mypassphrase!;
Re: How to handle password protected zipfiles
by Anonymous Monk on Dec 01, 2004 at 13:45 UTC
    Thanks for the info... Little confused with intentional input; This is what I understand --> I catfile my zip to a forwarding directory and the next line qx the intended zip file? My results are showing "The system cannot find the path specified". Not sure where the logic is failing me or if pkzip has problems with unc paths. $pkzip=File::Spec->catfile'$data_file','to','$data_control_dir'); qx!$pkzip -extract -pass XM#ip82# $data_file!;
      I would suggest reading what File::Spec does. That line is simply building the path to wherever pkzipc.exe is located (assuming that is the name of the binary you are using) and assigning that to $pkzip. Its just a convenient shortcut. Of course, this assumes that you have pkzip (or some other commandline based zip utility) installed (Winzip does not work because it is a GUI, there is a commandline plug-in for it, but it costs). You will also need to read up on qx!! (or other methods for making system type calls with Perl - see the Camel Book or other online documentation for Perl).
        I don't see the point in using File::Spec to construct the path for an executable on Windows only.

        If you were to actually go search for the program in PATH — or should I say, File::Spec->path — then I could understand. Now you're just acting silly.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://411439]
Approved by zejames
Front-paged by grinder
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2017-09-22 02:03 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (255 votes). Check out past polls.