Search code examples
bashamazon-s3wgetunzip

unzip unable to open archive when run from a script


When I run these commands together, the 'unzip' says:

"unzip: cannot find or ope /tmp/SOME.zip, /tmp/SOME.zip.zip, or /tmp/SOME.zip.ZIP"

wget https://s3-us-west-1.amazonaws.com/x/y/z/SOME.zip -O /tmp/SOME.zip
unzip /tmp/SOME.zip -d /opt

However, when I run them individually, they both work successfully on their own.

Other details:

  1. The bytes/size of SOME.zip bytes is the same regardless of approach
  2. When 'unzip' fails, the SOME.zip file looks like this "SOME.zip?"
  3. OS -Ubuntu 14.x
  4. Running script and individual commands as 'sudo'
  5. No gzip or encryption on the SOME.zip file

Solution

  • try putting the commands together:

    wget https://s3-us-west-1.amazonaws.com/x/y/z/SOME.zip -O /tmp/SOME.zip && unzip /tmp/SOME.zip -d /opt