Why I used Python to unzip a file

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 have been tasked with migrating over to wordpress.com.
Picture wordpress.com now:
Requires importing with large XML files, no access to the server via terminal, no access to mysql, no logs, only wp-admin via front end.
I needed to install a plugin on the site I’m migrating from but could not through the admin panel because its locked down.


Normally, I would just download the plug in and run scp from local to remote to get it to where it has to go.
That looks like this:
cd /to/install/dir
scp serveraddres:/dir/to/save/file/to

Enter your ssh password and thats it.

Alternate path…

However, sometimes I am already ssh’d into the server and this was one of those occasions. I could have opened a new terminal tab and did the above but again trying to expedite in the least amount of steps.
What I did was use curl to download the file to the server from source skipping the step of putting it on my machine first to then copy it to the server.
That looks like this:
curl http://sitename.com/wp-fileIwant.zip –output wp-fileIwant.zip
Great the file is on the server.
So I tried first running unzip to no avail because it wasn’t installed.
Then I tried installing unzip and that was a no go for some reason i didn’t feel like debugging. I am wary of the rabbit holes that persistently force us devs to context switch.
Then I came across this gem:

Which funnily enough, I could not open with nano, or emacs because neither was installed. So vim came in handy here.
Wrote the code and saved it in the dir.
Then I ran it. That looked like this:
python unzip.py wp-fileIwant.zip
And lo and behold my file was unzipped.
I could activate it via the front end and do what I needed.
Thus, python.

Link: https://dev.to/alvinmilton/why-i-used-python-to-unzip-a-file-a2b