开发者

Unable to create file with correct permissions using Net::SSH library

开发者 https://www.devze.com 2023-04-12 04:08 出处:网络
I\'m having troubles correctly setting file permissions using the Net::SSH library. Although I can correctly set the file\'s permissions after creating it, I need the file to have the correct permissi

I'm having troubles correctly setting file permissions using the Net::SSH library. Although I can correctly set the file's permissions after creating it, I need the file to have the correct permissions in the instance it's created. I'm connecting to an Ubuntu machine, and the ssh user has full permissions in the开发者_如何学编程 directory.

Here's a simplified version of the code illustrating where it's failing.


Net::SFTP.start('servername', 'username', :password => 'password') do |sftp|
  file_handle = sftp.open!('/remote/file/path', 'w', :permissions => 0777)
  # file has permissions 0755, but should have 0777
  sftp.fsetstat!(file_handle, {:permissions => 0777})
  # file now has correct 0777 permissions
  ...
end

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号