1

when trying to transfer the file like .txt .xml etc. But when transferring whole directory to another it is giving error. let me know what is wrong with the code. why it is not transferring the directories

import paramiko
import os

paramiko.util.log_to_file('/tmp/paramiko.log')

host = '10.2.216.195'
t = paramiko.Transport((host))

t.connect(username = 'stack',password = 'flow')

sftp = paramiko.SFTPClient.from_transport(t)

filepath = '/home/proteek'
localpath = '/home/proteek/newfolder/movie'

sftp.get(localpath,filepath)
sftp.close()
t.close()

it is giving an error which is

 File "/usr/lib/python2.6/site-packages/paramiko/sftp_client.py", line 599, in get
    fl = file(localpath, 'wb')
IOError: [Errno 21] Is a directory: '/home/proteek/movie'
Prateek
  • 21
  • 2
  • http://stackoverflow.com/questions/4409502/directory-transfers-on-paramiko try this – Marc vT Feb 08 '17 at 09:44
  • sorry i'm new with python could you tell how do I combine os.walk() – Prateek Feb 08 '17 at 09:48
  • I am honestly not 100% sure because I am unable to run any test code at the moment. Nevertheless, my quick google search seems to suggest that it is quite difficult/not possible to transfer a folder. You could use os.walk to loop through all the files in a directory and copy them to the new folder. Hopefully someone with a bit more insight will come around with some ideas – Marc vT Feb 08 '17 at 10:01

0 Answers0