Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.
Good morning
I have an issue where I'm writing a CSV file to the root folder of the IFS and I noticed that public does not have access to read or write authority. Is there a way to change this programatically?
Thanks for input!
How are you writing it?
You need to set the "mode" parameter to include the group authorities, in addition to the user authorities.
mode_t fmode = S_IRWXU | S_IRWXO | S_IRWXG;
If you need to do it after the file is created, you can use CHGAUT. I had to use this for files created by a qsh('jar...').
Ah, Dale's comment made me realize you said "change this" as in change the existing file, where as I assumed you ment you wanted to modify the program that was creating your CSV. So CHGAUT is easiest. If you want to use the API to do that, it is:
chmod( ifsFileName, newModeFlags)
In RPG:
D chmod PR 10I 0 extProc(*CWIDEN :'chmod') D path * Value OPTIONS(*STRING:*TRIM) D mode 10U 0 Value