Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set password to a ZIP using a script?

Status
Not open for further replies.

mackpei

Programmer
Jun 6, 2000
27
DE
Hi,

I want to use ZIP to compress a lot of files and set password on ZIP files generated in a script.

But how can do this automatically without prompting password input each time?

I tried echo "mypasswd" | zip ... and zip ... < mypasswd.txt

But they don't work on my Solaris.

Any hints?

TIA
Mack
 
Which version of zip are you using? (try zip -V) Which version of Solaris?

Annihilannic.
 
I am using the option "-e".

Here is the version info:

$ zip -v
Copyright (C) 1990-1997 Mark Adler, Richard B. Wales, Jean-loup Gailly,
Onno van der Linden and Kai Uwe Rommel.
Type 'zip -L' for the software License.
This is Zip 2.2 (November 3rd 1997), by Info-ZIP.
Currently maintained by Onno van der Linden. Please send bug reports to
the authors at Zip-Bugs@lists.wku.edu; see README for details.

Latest sources and executables are at ftp://ftp.cdrom.com/pub/infozip, as of
above date; see for other sites

Compiled with cc for Unix (Sun Sparc/Solaris) on Nov 15 1997.

Zip special compilation options:
USE_EF_UT_TIME
[encryption, version 2.7 of 22 April 1997]

Zip environment options:
ZIP: [none]
ZIPOPT: [none]
 
Hmm... it seems like the default version supplied with Solaris doesn't support encryption, so you must have installed that version later.

Anyway, I think you will need to use expect to script this because it reads directly from the terminal. Note that it expect comes with a useful tool called autoexpect which will generate the expect script for you.

Annihilannic.
 
Well, the zip program on my Solaris does have the option "-e". The problem is that I must type password twice in an interactive mode:

$ echo 'my_lovely_pwd' | zip -e my_zip.zip my_big_file.txt
Enter password:
Verify password:
adding: my_big_file.txt (stored 78%)

If I program with getpass(3C), there is no such problem, I can just pipe a password or redirect a password stored in a file to my program in a script.

Autoexpect would work, but I have to include this to the package to our clients, that would be not very helpful.

Mack

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top