Midrange News for the IBM i Community


Posted by: Chris Proctor
Programmer Analyst
Columbia Sports Company
Portland, OR
CSV read/write authority on the IFS?
has no ratings.
Published: 06 May 2016
Revised: 09 May 2016 - 2881 days ago
Last viewed on: 28 Mar 2024 (3268 views) 

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.

CSV read/write authority on the IFS? Published by: Chris Proctor on 06 May 2016 view comments(3)

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!

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: CSV read/write authority on the IFS?
Posted: 7 years 10 months 22 days 10 hours 19 minutes ago
Edited: Fri, 06 May, 2016 at 14:30:09 (2884 days ago)

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;        

  • S_IROTH - General read permission
  • S_IWOTH - General write permission
  • S_IXOTH - General execute permission
  • S_IRWXO - Is all of the above

 

Posted by: DaleB
Premium member *
Reading, PA
Comment on: CSV read/write authority on the IFS?
Posted: 7 years 10 months 19 days 16 hours 33 minutes ago

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...').

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: CSV read/write authority on the IFS?
Posted: 7 years 10 months 19 days 15 hours 45 minutes ago

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