<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alvin Milton</title>
    <description>The latest articles on DEV Community by Alvin Milton (@alvinmilton).</description>
    <link>https://dev.to/alvinmilton</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F11571%2FidE5vB-S.jpeg</url>
      <title>DEV Community: Alvin Milton</title>
      <link>https://dev.to/alvinmilton</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alvinmilton"/>
    <language>en</language>
    <item>
      <title>Why I used Python to unzip a file</title>
      <dc:creator>Alvin Milton</dc:creator>
      <pubDate>Fri, 19 Apr 2019 16:09:42 +0000</pubDate>
      <link>https://dev.to/alvinmilton/why-i-used-python-to-unzip-a-file-a2b</link>
      <guid>https://dev.to/alvinmilton/why-i-used-python-to-unzip-a-file-a2b</guid>
      <description>&lt;p&gt;So my day has started like this:&lt;/p&gt;

&lt;p&gt;I'm ssh'd into a pretty locked down server in a data center.&lt;/p&gt;

&lt;p&gt;This server runs an instance of Wordpress that I have been tasked with migrating over to wordpress.com.&lt;/p&gt;

&lt;p&gt;Picture wordpress.com now: &lt;br&gt;
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.&lt;/p&gt;

&lt;p&gt;I needed to install a plugin on the site I'm migrating from but could not through the admin panel because its locked down.&lt;/p&gt;
&lt;h4&gt;
  
  
  Fine.
&lt;/h4&gt;

&lt;p&gt;Normally, I would just download the plug in and run scp from local to remote to get it to where it has to go.&lt;/p&gt;

&lt;p&gt;That looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd /to/install/dir
scp &amp;lt;filename&amp;gt; serveraddres:/dir/to/save/file/to
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enter your ssh password and thats it.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;Alternate path...&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;That looks like this:&lt;br&gt;
&lt;code&gt;curl http://sitename.com/wp-fileIwant.zip --output wp-fileIwant.zip&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Great the file is on the server.&lt;/p&gt;

&lt;p&gt;So I tried first running &lt;code&gt;unzip&lt;/code&gt; to no avail because it wasn't installed.&lt;br&gt;
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.&lt;/p&gt;

&lt;p&gt;Then I came across this gem:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Frhf0kyxz4db7jwzenqla.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Frhf0kyxz4db7jwzenqla.png" alt="all you need to unzip a file with python"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Which funnily enough, I &lt;em&gt;could not&lt;/em&gt; open with &lt;code&gt;nano&lt;/code&gt;, or &lt;code&gt;emacs&lt;/code&gt; because neither was installed. So &lt;code&gt;vim&lt;/code&gt; came in handy here.&lt;/p&gt;

&lt;p&gt;Wrote the code and saved it in the dir.&lt;/p&gt;

&lt;p&gt;Then I ran it. That looked like this:&lt;br&gt;
&lt;code&gt;python unzip.py wp-fileIwant.zip&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And lo and behold my file was unzipped.&lt;/p&gt;

&lt;p&gt;I could activate it via the front end and do what I needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thus, python.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>wordpress</category>
      <category>ssh</category>
      <category>terminal</category>
    </item>
  </channel>
</rss>
