0

Im newbie in python currently I was successfuly upload file via sftp using paramiko. but I want to delete that file in my local machine after upload process end successfully. Anyone can help ? below my script for upload file

import paramiko
import os
import glob
ssh_client =paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_client.connect(hostname='domain.com',username='root',password='root')
ftp_client=ssh_client.open_sftp()
ftp_client.put('C:/testfile.txt','./testfile.txt')
ftp_client.close()

I don't know how to delete after upload has been success.

martineau
  • 119,623
  • 25
  • 170
  • 301
potitit
  • 63
  • 1
  • 8
  • Does this answer your question? [How to delete a file or folder?](https://stackoverflow.com/questions/6996603/how-to-delete-a-file-or-folder) – Random Davis Sep 23 '20 at 16:22
  • I mean in my case I uploading big file. How i know when my upload file has been success then I will delete that file in my local machine. – potitit Sep 23 '20 at 17:07
  • So your actual question isn't how to delete a file, it's how to know if uploading is done. If file deletion has nothing to do with your question, then don't mention it, since it's obviously confusing everyone. – Random Davis Sep 23 '20 at 17:24

1 Answers1

1
import os
os.remove("file.csv")
luisvenezian
  • 441
  • 5
  • 18