3

これが私のスクリプトです

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

Themes.zip である保護された 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

unzip -P password Themes.zip

出口0

于 2017-05-05T06:43:48.443 に答える