views:

123

answers:

2

I am getting an error whenever i try to run following unzip command from a python script which is running as a daemon

Command :

unzip abcd.zip > /dev/null

Error

End-of-central-directory signature not found$ a zip file, 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

unzip:  cannot find zipfile directory in one of abcd.zip$
        abcd.zip.zip, and cannot find abcd.zip.ZIP, period.

Could anyone help me in this regard?

Thanks in advance.

+1  A: 

Usually that would mean exactly what it says: that the file abcd.zip is not a valid ZIP file. Are you able to unzip abcd.zip as a normal user? If not, it would seem to have become corrupted. How did you get hold of it? Check for newline-mangling operations like ASCII-mode FTP.

Can you read the file with the built-in Python zipfile module? Handling files directly in Python is generally preferable to kicking it out onto the command line.

bobince
i can able to unzip the same file as a normal user
Fedrick
I even tested the zip file with unzip -t option to verify it, but when i run that from python daemon i am getting this error for some files
Fedrick
i validated the file its not corrupted
Fedrick
After a while same files are getting unzipped successfully,i would like to know the reason why this error is getting displayed
Fedrick
There is no reason I can think of why some files would fail to unzip and then later succeed. Is it possible that the files are in the middle of being created, eg. that they're being downloaded from another server, so appear to be incomplete until the download is finished?
bobince
No its sure that all files are complete before they get unzipped
Fedrick
A: 

Validate the file first. This looks like a corrupted/invalid zip file.

Noufal Ibrahim
i validated the file its not corrupted
Fedrick