Skip to content Skip to sidebar Skip to footer

Python Script For Creating Zip File In Remote Server

I want to write a python script that connects to the remote server and creates a zip file in the remote server which consists of specific files present in remote server itself. I h

Solution 1:

When you create the zip-file you refer to a local file files.zip:

zf = zipfile.ZipFile('files.zip', mode='w')

You never tell it to create the file remotely. But you could probably (haven't tried it myself) create a remote file and send the handle to ZipFile. The issue with that is that you will run the zipping on you local machine instead of on the remote machine. That will have all your files be moved over network back and forth to no use other than creating the remote file. Try to do the zipping directly on the remote machine instead!

Solution 2:

As UlfR says, "Try to do the zipping directly on the remote machine".  Since he (she?) didn't say how to do that, I suggest something like

c.exec_command("zip files.zipa.txtb.txt c.txt")

Post a Comment for "Python Script For Creating Zip File In Remote Server"