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
(NOTzip
) - 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, likeziSvbYhy
orzi3gzEQ4
.