How to copy the file from source to destination only once at a time?

Posted by Viswa on Ask Ubuntu See other posts from Ask Ubuntu or by Viswa
Published on 2012-11-16T04:35:40Z Indexed on 2012/11/16 5:13 UTC
Read the original article Hit count: 187

Filed under:

I have to copy the file from my desktop to my mounted directory. I was using the following command to copy the file from my desktop to mounted directory.

 os.system("cp -f /home/Desktop/filename /media/folder_1"). 

It works fine. But the problem is while copying the file from my source to mounted directory(folder_1) if any interruption is happens like network down, then the system continuously keep on trying. It couldn't skip that process. Finally, when the network comes the files are again copy to my mounted directory. Due to this continuous trying, next time i try to move the content it throws "permission denied" error.

How do i copy the file only once, if any network issues happen then it will not keep try to copy, instead of that, it throws the error. If you know, Let me. Its very useful to me.

© Ask Ubuntu or respective owner

Related posts about python