8 Replies Latest reply: Feb 15, 2013 6:57 AM by Dude! RSS

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


      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.

      SHIYAS M