Quantcast
Channel: Active questions tagged expect - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 157

How to use `expect` with `zipcloak`?

$
0
0

I create a zip file using zip which includes several files and directories, named test.upd. Now I want to use expect to automatically handle the password encryption. Here are two bash scripts, both do not work:

!/bin/bashMYPWD="mypassword"expect -c '    spawn zipcloak test.upd    expect {"*Enter password*" { send "'"$MYPWD"'\r"                                   exp_continue                                  }"*Verify password*" { send "'"$MYPWD"'\r"                                      exp_continue                                    }    }'

and this file:

!/bin/bashMYPWD="mypassword"expect -c '    spawn zipcloak test.upd    expect "*Enter password*"    send "'"$MYPWD"'\r"    expect "*Verify password*"    send "'"$MYPWD"'\r"    }'

I also tried to create an expect script directly:

#!/usr/bin/expect -fspawn zipcloak test.updexpect "*Enter password*"send "password\r"expect "*Verify password*"send "password\r"

All scripts seem to send correctly the first password request, but it looks like the text for the second password entry is never asked. How can I do it right?

Constraints:

  • I have to use zipcloak (NOT zip)
  • I want to use expect to automatically set the password.

Remarks:

  • I have used the correct script
  • Each time, when using the first script, an empty file starting with zi is created in the directory, like ziSvbYhy or zi3gzEQ4.

Viewing all articles
Browse latest Browse all 157

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>