Unable to extract zip in python to destination folder(server) from my local host
<p>I'm unable to extract zip file in python to destination folder(server) from my local host. While extracting using <code>z.extract(name,"/destination/")</code>, it's unable to find destination folder as it is trying to search destination folder locally instead of the server.</p>

<pre><code>    transport = paramiko.Transport((destinationIP))
    transport.connect(username = destinationuserName, password =   destinationPassword)
    sftp = paramiko.SFTPClient.from_transport(transport)

    fh = sftp.open('/destination/xxx.zip', 'rb')
    z = zipfile.ZipFile(fh)
    for name in z.namelist():
        print name
        z.extract(name,"/destination/") 
    fh.close()
    sftp.close()
</code></pre>

<p>It appears you would like the extracted files to appear on the server, even though you are extracting them on the client machine. Unfortunately that isn't going to fly, as the <code>zipfile.extract</code> method assumes that its second argument is a local path.</p>

<p>You <em>could</em> consider creating a local temporary directory in which to extract the files, but then you will have to copy each file back to its desired destination on the server. This doesn't seem like a sensible use of distributed resources, but if you don't have shell access to the server it might be the best you can do.</p>

<p>If you <em>do</em> have shell access to the server then consider using something like <code>fabric</code> or <code>paramiko</code> to execute the necessary commands on the server system.</p>

python ssh sftp paramiko