DEV Community

Why I used Python to unzip a file

Alvin Milton on April 19, 2019

So my day has started like this: I'm ssh'd into a pretty locked down server in a data center. This server runs an instance of Wordpress that I ha...
Collapse
 
ericfrederich profile image
Eric L. Frederich •

I've been in a locked down Docker container for a GitLab runner. Didn't feel like atp-get, yum, or apk installing unzip. You don't need that script, you can run Python's unzip as a module...

python -m zipfile whatever.zip

... Or something like that.

Collapse
 
alvinmilton profile image
Alvin Milton •

Hey Eric,
I tried this and it didn't work locally or on the server.
Can you clarify?

Collapse
 
serhiystorchaka profile image
Serhiy Storchaka •

Try just
python3 -e wp-fileIwant.zip .

Collapse
 
alvinmilton profile image
Alvin Milton •

tried it.
got unknown option -e as a response...

Collapse
 
serhiystorchaka profile image
Serhiy Storchaka •

Sorry, some words were missed. The correct line is:
python3 -m zipfile -e wp-fileIwant.zip .

Collapse
 
aduen profile image
Aduen Darriba Frederiks •

tar can also be used for decompressing zip files in most cases

Collapse
 
alvinmilton profile image
Alvin Milton •

Totally forgot about tar!

Collapse
 
elabftw profile image
eLabFTW • • Edited

Enter your ssh password

Have you heard about ssh keys? ;p

Collapse
 
alvinmilton profile image
Alvin Milton •

If you are referring to adding my key to ssh-agent, I just did that.

Thanks for the tip.

Collapse
 
mastereuclid profile image
Kyle M. •

Cute story. Made me smile. Took my mind off the grind for a second.

Collapse
 
alvinmilton profile image
Alvin Milton •

Glad to hear!

Collapse
 
mujeebishaque profile image
Mujeeb Ishaque •

Awesome write-up. Thanks, Alvin.

Collapse
 
alvinmilton profile image
Alvin Milton •

thanks. appreciated.