Skip to main content
Spelling, grammar, formatting
Source Link
Toby Speight
  • 9.3k
  • 3
  • 32
  • 54

I'm trying to make a script that will unzip a password protected file, the password being the name of the file that I will get when unzipping

Eg.

file1.zip contains file2.zip and it's password is file2.

file2.zip contains file3.zip and it's password is file3
  • file1.zip contains file2.zip and its password is file2.
  • file2.zip contains file3.zip and its password is file3

How do I unzip file1.zip, and read the name of file2.zip so it can be entered in the script?

Here's a screenshot of the command line: Here's a screenshot of what I meant

root@kaliVM:~/Desktop# unzip 49805.zip
Archive: 49805.zip
[49805.zip] 13811.zip password:

root@kaliVM:~/Desktop# unzip 49805.zip  
Archive:  49805.zip  
[49805.zip]  13811.zip password:  

I just need bashBash to read that output in order to know the new password (In this case the password is 13811).

Here's what I've done so far

    #!/bin/bash

    echo First zip name:
    read firstfile


    pw=$(zipinfo -1 $firstfile | cut -d. -f1)
    nextfile=$(zipinfo -1 $firstfile)
    unzip -P $pw $firstfile

    rm $firstfile
    nextfile=$firstfile
#!/bin/bash

echo First zip name:
read firstfile


pw=$(zipinfo -1 $firstfile | cut -d. -f1)
nextfile=$(zipinfo -1 $firstfile)
unzip -P $pw $firstfile

rm $firstfile
nextfile=$firstfile

Now how can I make it do the loop?

I'm trying to make a script that will unzip a password protected file, the password being the name of the file that I will get when unzipping

Eg.

file1.zip contains file2.zip and it's password is file2.

file2.zip contains file3.zip and it's password is file3

How do I unzip file1.zip, and read the name of file2.zip so it can be entered in the script?

Here's a screenshot of the command line: Here's a screenshot of what I meant

root@kaliVM:~/Desktop# unzip 49805.zip
Archive: 49805.zip
[49805.zip] 13811.zip password:

I just need bash to read that output in order to know the new password (In this case the password is 13811).

Here's what I've done so far

    #!/bin/bash

    echo First zip name:
    read firstfile


    pw=$(zipinfo -1 $firstfile | cut -d. -f1)
    nextfile=$(zipinfo -1 $firstfile)
    unzip -P $pw $firstfile

    rm $firstfile
    nextfile=$firstfile

Now how can I make it do the loop?

I'm trying to make a script that will unzip a password protected file, the password being the name of the file that I will get when unzipping

Eg.

  • file1.zip contains file2.zip and its password is file2.
  • file2.zip contains file3.zip and its password is file3

How do I unzip file1.zip, and read the name of file2.zip so it can be entered in the script?

Here's a screenshot of the command line: Here's a screenshot of what I meant

root@kaliVM:~/Desktop# unzip 49805.zip  
Archive:  49805.zip  
[49805.zip]  13811.zip password:  

I just need Bash to read that output in order to know the new password (In this case the password is 13811).

Here's what I've done so far

#!/bin/bash

echo First zip name:
read firstfile


pw=$(zipinfo -1 $firstfile | cut -d. -f1)
nextfile=$(zipinfo -1 $firstfile)
unzip -P $pw $firstfile

rm $firstfile
nextfile=$firstfile

Now how can I make it do the loop?

I'm trying to make a script that will unzip a password protected file, the password being the name of the file that I will get when unzipping

Eg.

file1.zip contains file2.zip and it's password is file2.

file2.zip contains file3.zip and it's password is file3

How do I unzip file1.zip, and read the name of file2.zip so it can be entered in the script?

Here's a screenshot of what I meant, Here's a screenshot of the command line: Here's a screenshot of what I meant

root@kaliVM:~/Desktop# unzip 49805.zip
Archive: 49805.zip
[49805.zip] 13811.zip password:

I just need bash to read that output in order to know the new password (In this case the password is 13811).

Here's what I've done so far

    #!/bin/bash

    echo First zip name:
    read firstfile


    pw=$(zipinfo -1 $firstfile | cut -d. -f1)
    nextfile=$(zipinfo -1 $firstfile)
    unzip -P $pw $firstfile

    rm $firstfile
    nextfile=$firstfile

Now how can I make it do the loop?

I'm trying to make a script that will unzip a password protected file, the password being the name of the file that I will get when unzipping

Eg.

file1.zip contains file2.zip and it's password is file2.

file2.zip contains file3.zip and it's password is file3

How do I unzip file1.zip, and read the name of file2.zip so it can be entered in the script?

Here's a screenshot of what I meant, I just need bash to read that output in order to know the new password (In this case the password is 13811).

Here's what I've done so far

    #!/bin/bash

    echo First zip name:
    read firstfile


    pw=$(zipinfo -1 $firstfile | cut -d. -f1)
    nextfile=$(zipinfo -1 $firstfile)
    unzip -P $pw $firstfile

    rm $firstfile
    nextfile=$firstfile

Now how can I make it do the loop?

I'm trying to make a script that will unzip a password protected file, the password being the name of the file that I will get when unzipping

Eg.

file1.zip contains file2.zip and it's password is file2.

file2.zip contains file3.zip and it's password is file3

How do I unzip file1.zip, and read the name of file2.zip so it can be entered in the script?

Here's a screenshot of the command line: Here's a screenshot of what I meant

root@kaliVM:~/Desktop# unzip 49805.zip
Archive: 49805.zip
[49805.zip] 13811.zip password:

I just need bash to read that output in order to know the new password (In this case the password is 13811).

Here's what I've done so far

    #!/bin/bash

    echo First zip name:
    read firstfile


    pw=$(zipinfo -1 $firstfile | cut -d. -f1)
    nextfile=$(zipinfo -1 $firstfile)
    unzip -P $pw $firstfile

    rm $firstfile
    nextfile=$firstfile

Now how can I make it do the loop?

Tweeted twitter.com/StackUnix/status/1027208320778752001
added 334 characters in body
Source Link

I'm trying to make a script that will unzip a password protected file, the password being the name of the file that I will get when unzipping

Eg.

file1.zip contains file2.zip and it's password is file2.

file2.zip contains file3.zip and it's password is file3

How do I unzip file1.zip, and read the name of file2.zip so it can be entered in the script?

Here's a screenshot of what I meant, I just need bash to read that output in order to know the new password (In this case the password is 13811).

Here's what I've done so far

    #!/bin/bash

    echo First zip name:
    read firstfile


    pw=$(zipinfo -1 $firstfile | cut -d. -f1)
    nextfile=$(zipinfo -1 $firstfile)
    unzip -P $pw $firstfile

    rm $firstfile
    nextfile=$firstfile

Now how can I make it do the loop?

I'm trying to make a script that will unzip a password protected file, the password being the name of the file that I will get when unzipping

Eg.

file1.zip contains file2.zip and it's password is file2.

file2.zip contains file3.zip and it's password is file3

How do I unzip file1.zip, and read the name of file2.zip so it can be entered in the script?

Here's a screenshot of what I meant, I just need bash to read that output in order to know the new password (In this case the password is 13811).

I'm trying to make a script that will unzip a password protected file, the password being the name of the file that I will get when unzipping

Eg.

file1.zip contains file2.zip and it's password is file2.

file2.zip contains file3.zip and it's password is file3

How do I unzip file1.zip, and read the name of file2.zip so it can be entered in the script?

Here's a screenshot of what I meant, I just need bash to read that output in order to know the new password (In this case the password is 13811).

Here's what I've done so far

    #!/bin/bash

    echo First zip name:
    read firstfile


    pw=$(zipinfo -1 $firstfile | cut -d. -f1)
    nextfile=$(zipinfo -1 $firstfile)
    unzip -P $pw $firstfile

    rm $firstfile
    nextfile=$firstfile

Now how can I make it do the loop?

deleted 121 characters in body; edited tags
Source Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 264
Loading
added 1 character in body
Source Link
GAD3R
  • 69.8k
  • 32
  • 147
  • 216
Loading
added 141 characters in body
Source Link
Loading
Source Link
Loading