-1

I am writing a python program in which i want to move a directory and its file to another server my code is as below

import paramiko

client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

client.connect('ipaddr', username='username',password='password')
print ("copying")
sftp = client.open_sftp()
sftp.put('/home/source/workspace/vddir', '/home/destination/workspace/vddir')
sftp.close()

But it shows error like this

Traceback (most recent call last):
  File "pycode.py", line 9, in <module>
    sftp.put('/home/source/workspace/vddir', '/home/destinatiob/workspace/vddir')
  File "/usr/local/lib/python3.6/dist-packages/paramiko/sftp_client.py", line 758, in put
    with open(localpath, "rb") as fl:
IsADirectoryError: [Errno 21] Is a directory: '/home/appadmin/workspace/vdcode'

please help ..thanks in advance

  • https://stackoverflow.com/questions/29341975/move-files-from-one-directory-to-another-with-paramiko your query might be answered here, kindky check. – The Name is Psycho Jun 10 '21 at 05:36
  • Your traceback and code don't match - in the traceback source and destination are the same. – tdelaney Jun 10 '21 at 05:36
  • put is for a single file, see [docs](http://docs.paramiko.org/en/stable/api/sftp.html#paramiko.sftp_client.SFTPClient.put) – tdelaney Jun 10 '21 at 05:40
  • Do you want to [***move***](https://stackoverflow.com/q/29341975/850848#29342715) or [***copy***](https://stackoverflow.com/q/4409502/850848#62057641)? – Martin Prikryl Jun 10 '21 at 05:55
  • @MartinPrikryl copy – TONY FRANK C Jun 10 '21 at 06:02
  • So why does your question say "move"? Anyway, your question is duplicate then. – Seeing your question history, please do some research before asking. Most of your questions end up closed as duplicates. – Martin Prikryl Jun 10 '21 at 07:00

1 Answers1

-1

The problem is you can’t move an entire folder in one go you have to walk though the files and upload them one by one. This should answer your question: https://stackoverflow.com/a/19974994/7838574

Daniel Butler
  • 3,239
  • 2
  • 24
  • 37