Trying to Net::SFTP download but get Errno::EACCES: Permission denied - Directory I'm copying to

StackOverflow https://stackoverflow.com/questions/16279901

  •  13-04-2022
  •  | 
  •  

문제

I'm trying to copy a file from a Unix box to my local desktop but I'm getting the error: Errno::EACCES: Permission denied - C:\Users\MyUser\Desktop

require 'net/sftp'
Net::SFTP.start(unixBox, user, :password => password) do |sftp|
  sftp.download!(filePathOnUnixBox, 'C:\Users\MyUser\Desktop')
end

My Desktop: Windows 7

ruby 1.8.7 (2010-12-23 patchlevel 330) [i386-mingw32]

net-sftp (2.1.1)

Unix box: SunOS

UPDATE: Looks like you have to specify the filename in your TO file path so C:\Users\MyUser\Desktop becomes C:\Users\MyUser\Desktop\fileNameIWant.ext

도움이 되었습니까?

해결책 3

Looks like you have to specify the filename in your TO file path so C:\Users\MyUser\Desktop becomes C:\Users\MyUser\Desktop\fileNameIWant.ext

Before I was only specifying the path but not the file name.

다른 팁

Looks like the user that's running the ruby script does not have permission to write to your HDD. Maybe MyUser is not the user that's executing the script.

EDIT:

Forgot to mention, you could try and escape the windows backslashes. Try:

C:\\Users\\MyUser\\Desktop

as the local path

One thing you can do to avoid madness, is stop using backslashes in Windows filenames when using Ruby. Per the IO documentation:

Ruby will convert pathnames between different operating system conventions if possible. For instance, on a Windows system the filename "/gumby/ruby/test.rb" will be opened as "\gumby\ruby\test.rb". [...]

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top