Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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
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 file.zip!;
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://411439]
Approved by zejames
Front-paged by grinder
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2014-07-14 01:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (254 votes), past polls