Automating the password protected zip file creation in linux server

Midhun 123
Midhun 123 used Ask the Experts™
Hi Experts,

I have linux script which is working fine for creating password protected zip file (zip file will contain csv file) .Please find the same below.
Zip -e -rj  /input/file/path/*.csv 

Open in new window

This command will ask user input ,ie password.It will be like below.
Enter password:

Open in new window

 we need to provide password..Then it will ask for confirmation like this
Verify password:

Open in new window

again we need to provide password..Done..It will create a password protected zip file.

Now I need to automate this script..It should not ask for user input..
Can anyone help me how to write script for automating this task.
Any help regarding this would be highly appreciated.

Thanks in Advance.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Trying to tame bits. They're nasty.
zip -e -P <password> -rj  /input/file/path/*.csv
Martyn SpencerSoftware Developer / Linux System Administrator / Managing Director
Mihai Barbos' answer is correct. Please do bear in mind that providing a password this way could be considered insecure if not properly handled. Take a look at the man page for zip, which states:

Use password to encrypt zipfile entries (if any).  THIS IS INSECURE!   Many  multi-user  operating systems provide ways for any user to see the current command line of any other user; even on stand-alone  systems  there  is  always  the threat of over-the-shoulder peeking.  

Storing the plaintext password as part  of  a command  line  in  an  automated script is even worse.  Whenever possible, use the non-echoing, interactive prompt to enter pass‐words.   (And  where  security  is  truly  important, use strong encryption such as Pretty Good Privacy instead of the relatively weak standard encryption provided by zipfile utilities.)
Midhun 123Application developer


Thank You so  much Mihai and Martyn.

You made my day..

All the best..keep helping people.. :-) :-)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial