13

Permission Denied When You Try to Copy Shared Files to a Local Drive to Ruby

 2 years ago
source link: https://www.codesd.com/item/permission-denied-when-you-try-to-copy-shared-files-to-a-local-drive-to-ruby.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Permission Denied When You Try to Copy Shared Files to a Local Drive to Ruby

advertisements

Here is my very basic copy code:

require 'fileutils'
FileUtils.copy_file("\\\\winmomfs1\\3rdParty\\Oracle Client\\Oracle_11gR2\\win64_11gR2_client.zip","c:\\chef-tmp")

Here is the error I get:

C:\Users\ctote\Desktop>ruby cp.rb C:/opscode/chef/embedded/lib/ruby/1.9.1/fileutils.rb:1371:in `initialize': Permission denied - c:/chef-tmp (Errno::EACCES)
        from C:/opscode/chef/embedded/lib/ruby/1.9.1/fileutils.rb:1371:in `open'
        from C:/opscode/chef/embedded/lib/ruby/1.9.1/fileutils.rb:1371:in `block in copy_file'
        from C:/opscode/chef/embedded/lib/ruby/1.9.1/fileutils.rb:1370:in `open'
        from C:/opscode/chef/embedded/lib/ruby/1.9.1/fileutils.rb:1370:in `copy_file'
        from C:/opscode/chef/embedded/lib/ruby/1.9.1/fileutils.rb:477:in `copy_file'
        from cp.rb:2:in `<main>'

What am I doing wrong? I can manually copy these files through explorer, so I don't think it's a permissions thing.


I think you should use FileUtils::cp_r and write code as below :

require 'fileutils'

FileUtils.cp_r("\\\\winmomfs1\\3rdParty\\Oracle Client\\Oracle_11gR2\\win64_11gR2_client.zip","c:\\chef-tmp")

Look this post - Ruby-FileUtils copy_file Permission denied on Windows

Tags ruby

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK