?
Solved

Unzip a file using perl script

Posted on 2003-02-21
6
Medium Priority
?
1,750 Views
Last Modified: 2012-08-14
I have a CGI script for uploading .zip files, unzipping the file, and then display success message. I am able to upload the zip file to my server. However, I cannot get Perl to unzip the file.

Here is the code snippet:

$output = `unzip $filename 2>&1`;
print "$output";


Here is the ouput I receive:

Archive: test1.zip End-of-central-directory signature not found. Either this file is not a zipfile, or it constitutes one disk of a multi-part archive. In the latter case the central directory and zipfile comment will be found on the last disk(s) of this archive. note: test1.zip may be a plain executable, not an archive unzip: cannot find zipfile directory in one of test1.zip or test1.zip.zip, and cannot find test1.zip.ZIP, period.

Can someone help?
0
Comment
Question by:kimanh
6 Comments
 
LVL 2

Expert Comment

by:Itatsumaki
ID: 7994456
Check the integrity of the zip file.  Also, did you give the zip-file proper permissions to be accessible by the CGI script?

When I run your code snippet directly it works fine.
0
 

Expert Comment

by:awwaiid
ID: 7994459
Sounds like your uploading is borked. I'd try to unzip it by hand to make sure it works okay.
0
 
LVL 27

Expert Comment

by:wilcoxon
ID: 7995701
Definitely looks like the zip file was corrupted during the upload.  Check the integrity of the file manually.

You might also want to check out Archive::Zip instead of shelling out to call unzip.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:kimanh
ID: 8148450
I apologize to those who replied to my question. Sorry, I do not know how things work here. I have found the answer to my problem.

The unzip program on my server at work did not accept just
`unzip $filename 2>&1`;

After reading through the man page for unzip a few times, I was able to get it working with:

system("/usr/bin/unzip -o $filename -d $specifiedDir");

The "-o" option was to overwrite the files each time and "-d" was required if I want the files unzipped to a specified directory.
0
 

Expert Comment

by:SpideyMod
ID: 8148527
A request for refund has been made.  Experts, you have 72 hours to object.  Without feedback, I intend to honor the request with a PAQ/Refund.

SpideyMod
Community Support Moderator @Experts Exchange
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 8167306
PAQ'd and all 50 points refunded

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question