1

I'm invoking this command from an application I write.

zip -rm9T --password pass123 /home/cats.zip /home/cats-data/

I'm setting a password to the archive and I'm specifying that the archive's integrity should be checked after it's creation with the -T switch.

The problem is that the 2 things don't work well with each other.

The archiving part goes well, but when it tries to check the integrity of the archive it doesn't know the password and expects it to come from stdin... I already gave it the password... I don't know why it needs it again... and in such a inconvenient way...

How can I make this work?

  • Not a fix (I could not get around the zip limitation either) but a workaround: Leave the testing to unzip as a second line in your script: unzip -t -P pass123 /home/cats.zip. – andrew.46 May 23 '18 at 21:59
  • This is exactly what I did. Make this into an answer and I will accept it. – Hristo Kolev May 25 '18 at 6:59
  • Great minds think alike :) – andrew.46 May 25 '18 at 10:19
1

There appears to be no good method to bypass this limitation with the zip application unfortunately. However if you are scripting this a good workaround is to use the unzip utility to test the zip file in the subsequent line of your script.

Thus you would have something like the following (omitting the -T option for zip):

zip -rm9 --password pass123 /home/cats.zip /home/cats-data/
unzip -t -P pass123 /home/cats.zip

And this should accomplish your goal!

Notes:

Options I have used for unzip are:

  • -t test archive files. This option extracts each specified file in memory and compares the CRC (cyclic redundancy check, an enhanced checksum) of the expanded file with the original file's stored CRC value.
  • -P use password to decrypt encrypted zipfile entries (if any).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.