Can't save new file even though I definitely have write permissions
106 views (last 30 days)
Show older comments
Daniel Klisiewicz
on 20 Dec 2023
Answered: Daniel Klisiewicz
on 22 Dec 2023
I'm trying to save a .mat file in the following manner:
save('/path/to/file/file.mat','var1','var2');
I'm getting the "Cannot save /path/to/file/file.mat: Permission denied" that you typically get when the user running Matlab does not have permissions to write to the directory specified.
The problem is I ABSOLUTELY have write permissions to /path/to/file.
The output to
ls -l '/path/to/'
shows the 'file' directory as drwxrwxr-x, and belongs to group "Developers", which I am a part of.
Further proof that I have write permissions: If I cd /path/to/file/ and then create a file named 'file.mat' using vim, and THEN invoke Matlab's save as described above, it WORKS!. If I then remove that file using a terminal and try to save from Matlab again, it FAILS!
Why might I not be able to create a new file from Matlab?
The only nuance I can think of is /path/to/file is an NFS mount on RHEL7
2 Comments
Walter Roberson
on 20 Dec 2023
I no longer recall... if /path/to/file is an NFS mount point, then does ls -l reflect the permissions of the underlying mount point, or does it reflect the permissions of the mounted filesystem ?
Accepted Answer
More Answers (1)
Sulaymon Eshkabilov
on 20 Dec 2023
Check the permission:
% Specify the path you want to check
folderPath = '/path/to/file/file.mat';
% Get file attributes
attributes = fileattrib(folderPath);
% Check if you have the write permission in the folder
if attributes==1
disp('Write permission is available for you! :)');
else
disp('Write permission is NOT available for you! :(');
end
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!