3

Can anyone tell me why I'm getting the following error:

Traceback (most recent call last):
  File "C:\Python27\connect.py", line 22, in <module>
    sftp.get(filepath, localpath)
  File "C:\Python27\lib\site-packages\paramiko-1.7.6-py2.7.egg\paramiko\sftp_client.py", line 603, in get
    fl = file(localpath, 'wb')
IOError: [Errno 13] Permission denied: 'C:\\remote'

I'm using Python 2.7 on a Windows 7 (as administrator) machine logging into an Ubuntu 10.10 machine. Here is the, very straight forward, script that I'm using:

import paramiko
import os




paramiko.util.log_to_file('c:\Python27\paramiko-wininst.log')

host = '192.168.1.14'
port = 22
transport = paramiko.Transport((host,port))
password = 'xxxxxx'
username = 'username'
transport.connect(username = username, password = password)

sftp = paramiko.SFTPClient.from_transport(transport)



filepath = '/home/my.log'
localpath = 'C:\\remote'
sftp.get(filepath, localpath)


sftp.close()
transport.close()
aculich
  • 14,545
  • 9
  • 64
  • 71
suffa
  • 3,606
  • 8
  • 46
  • 66
  • 1
    I'm not 100% sure, but don't you have to right click a script you want to run and click "Run as administrator" or something similar? (Even if you're user has administrator privileges) – thomasa88 May 01 '11 at 17:39
  • 1
    @thomasa88 - No, as long as you are in an administrator session 'full-control' should be granted. Right click -> "Run as administrator' is not an available option with Py scripts on my pc. – suffa May 01 '11 at 18:36
  • 2
    @user706808 Maybe the problem is that your localpath is a directory and not a file. If this is not the problem, have you tried writing to a file "manually" in a python script to c:\remote? Have you tried specifying another directory? – thomasa88 May 01 '11 at 18:45
  • 1
    @thomasa88 - that was it ... needed a file to create and not just a local directory. – suffa May 01 '11 at 19:05

1 Answers1

5

Try to make the following change

localpath = 'C:\\remote'
sftp.get(filepath, localpath)

modify it to

localpath = 'C:\remote\my.log'
sftp.get(filepath, localpath)
Lorenz Meyer
  • 19,166
  • 22
  • 75
  • 121
3xt
  • 66
  • 1
  • 8