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.
문제
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". [...]