Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stdin to zip command instead of prompt

Want to protect my ZIP archive with password.

Create archive with this:

zip -er archivename.zip file

and get this:

Enter password: 
Verify password: 

Everything is ok,but I have variable with password and need to send this password to zip. Tried through arguments like this, but failed.

echo "$1"| zip -er archivename.zip file

Is it possible in bash? Because zip utility does not support stdin.

like image 424
Alex Zern Avatar asked Feb 03 '26 07:02

Alex Zern


1 Answers

Read the man

For insecure solution, use -P:

-P|--password password Use password to encrypt zipfile entries (if any). THIS IS INSECURE!

User interaction

-e|--encrypt Encrypt the contents of the zip archive using a password which is entered on the terminal in response to a prompt

like image 76
Édouard Lopez Avatar answered Feb 04 '26 21:02

Édouard Lopez



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!