Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to avoid password prompt in shell script for zip password protection

Shiyas MohammadFeb 14 2013 — edited Feb 15 2013
Hi

I am trying to set password protection to my oracle database export backup. Once the backup completed, it should compress with a password protection. Thats the plan. Initialy we were using the gzip for the compression. Then realized that there is no password protection for the gzip. Started using zip option. I tried using

zip -P <password> filename

But it was throwing below error.

-bash-3.2$ zip -P expreports REPORTS_2013FEB14.dmp
zip warning: missing end signature--probably not a zip file (did you
zip warning: remember to use binary mode when you transferred it?)
zip warning: (if you are trying to read a damaged archive try -F)

zip error: Zip file structure invalid (REPORTS_2013FEB14.dmp)

Not quite sure why.

Then I used zip -e REPORTS_2013FEB14.dmp.zip REPORTS_2013FEB14.dmp
But this prompting for the password. As I am trying to put the command in the script. It will be tough if it prompts for the password.
I would like to know how to avoid the password prompting by saving somewhere or how the code should be written. Tried using expect feature of shell script. Below was the code I tried. It didnt work.

[oracle@SF40V6636 test]$ cat repexp.sh

zip -e REPORTS_imp.log.zip REPORTS_imp.log

expect "Enter password:"
send "imprep"
expect "Verify password:"
send "imprep"

So please help in avoiding this password prompt or let me know how to change the code.

Thanks
SHIYAS M
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 15 2013
Added on Feb 14 2013
8 comments
2,777 views