Python 2.7 を使用して、Linux サーバーからローカル マシン (Windows と Linux の両方) に SFTP を使用して、ファイルとサブフォルダーを含むディレクトリ構造全体を再帰的にコピーしたいと考えています。
サーバーに ping を実行し、同じマシンから WinSCP を使用してファイルをダウンロードできます。
次のコードを試してみましたが、Linux では正常に動作しますが、Windows では動作しません。
、、、すべて同じエラーが発生し、権限も確認しました\
。/
os.join
import os
import pysftp
cnopts = pysftp.CnOpts()
cnopts.hostkeys = None # disable host key checking.
sftp=pysftp.Connection('xxxx.xxx.com', username='xxx', password='xxx', cnopts=cnopts)
sftp.get_r('/abc/def/ghi/klm/mno', 'C:\pqr', preserve_mtime=False)
File "<stdin>", line 1, in <module> File "C:\Python27\lib\site-packages\pysftp_init_.py", line 311, in get_r preserve_mtime=preserve_mtime)
File "C:\Python27\lib\site-packages\pysftp_init_.py", line 249, in get self._sftp.get(remotepath, localpath, callback=callback)
File "C:\Python27\lib\site-packages\paramiko\sftp_client.py", line 769, in get with open(localpath, 'wb') as fl: IOError: [Errno 2] No such file or directory: u'C:\\pqr\\./abc/def/ghi/klm/mno/.nfs0000000615c569f500000004'