0

I have the following problem.

I need to replace a file with another one. As far as the new is transfered over the network, owner and group bits are lost.

So I have the following idea. To save current permissions and file owner bits and than after replacing the file restore them.

Could you please suggest how to do this in Python or maybe you could propose a better way to achieve this.

1 Answers1

0

You can use rsync facility to copy the file to remote location with same permissions. A simple os.system(rsync -av SRC <DEST_IP>:~/location/) call can do this. Another methods include using a subprocess.

hmehra
  • 21
  • 3
  • It won't work in my case, I have already downloaded files in tar archives –  Sep 19 '17 at 06:47