Automating the password protected zip file creation in linux server

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 zipfilename.zip  /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.
Midhun 123Application developerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mihai BarbosTrying to tame bits. They're nasty.Commented:
zip -e -P <password> -rj zipfilename.zip  /input/file/path/*.csv
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Martyn SpencerManaging DirectorCommented:
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.)
1
Midhun 123Application developerAuthor Commented:
Thank You so  much Mihai and Martyn.

You made my day..

All the best..keep helping people.. :-) :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.