3

好的,这是我的脚本

    #!/bin/bash
cd /var/backups/System/
unzip Themes.zip
exit 0

在解压缩受保护的 zip 文件(即 Themes.zip)时,我需要脚本自动输入密码。由于用户不知道密码,我需要在提取 zip 存档时通过脚本输入密码。希望这是因为?

4

2 回答 2

13

使用-P标志作为密码。来自man unzip

-P password
              use  password to decrypt encrypted 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 passwords.  (And where security is truly important, use strong encryption such as Pretty Good Privacy instead of the relatively weak encryption provided by standard  zipfile  utili-
              ties.)
于 2012-07-09T06:16:14.113 回答
3

解压 -P 密码 Themes.zip

出口 0

于 2017-05-05T06:43:48.443 回答