Reputation: 2461
I tried to open a file in this way
File.open(f_name, File::CREAT | File::RDWR) do |file|
end
Absolute file path is passed in as filename, such as filename is
/mounts/dd670-6.chaos.local/cifs/tfile6
Get the error message
Permission denied - /mounts/dd670-6.chaos.local/cifs/tfile6 (Errno::EACCES)
And, if I go into that directory and open that file, operation can be done successfully.
Anybody has any clue?
Upvotes: 1
Views: 4888
Reputation:
you can try change the perms before opening the file:
chmoded = 0
f_name = __FILE__
begin
File.open(f_name, File::CREAT | File::RDWR) do |file|
end
rescue => e
File.chmod(0755, f_name) rescue nil
chmoded += 1
retry if chmoded < 2
puts e.message
end
Upvotes: 2