11.12.2025, 16:08
Hello,
I'm experiencing file write permission issues and need help resolving them.
THE PROBLEM
I have JSON files that my JavaScript code can READ successfully via HTTP, but my LUA resident script CANNOT WRITE to these same files.
Files are located at: /user/data/event_definitions.json and /user/data/event_schedules.json
JavaScript reads them successfully via HTTP:
- fetch('/apps/data/event_definitions.json') → Works perfectly
- Files exist and are readable
LUA resident script attempts to write to: /user/data/event_definitions.json
- Result: Permission denied / Cannot open file for writing
WHAT WE'VE TRIED
1. Direct write using io.open(filepath, 'w'):
Result: Returns nil (cannot open file)
2. Added os.execute('chmod 777 /user/data'):
Result: No effect, still cannot write
3. Write to /tmp/ then copy using os.execute('cp /tmp/file.json /user/data/file.json'):
Result: Copy command returns exit code 256 (failure)
4. Write to /tmp/ then cat using os.execute('cat /tmp/file.json > /user/data/file.json'):
Result: Exit code 256 (failure), verification shows file not updated
FTP ACCESS
- When logged in via FTP as user "apps": Can see /user/data/ directory with the JSON files
- When logged in via FTP as user "ftp": Root folder is empty
QUESTION
What is the correct way to make /user/data/ writable by LUA resident scripts?
OR
What is the recommended directory for storing user data files that:
1. Can be written to by LUA scripts
2. Can be read via HTTP by JavaScript (fetch API)
3. Persists across reboots (not /tmp/)
4. Is accessible via FTP for backup purposes
Any guidance would be greatly appreciated!
I'm experiencing file write permission issues and need help resolving them.
THE PROBLEM
I have JSON files that my JavaScript code can READ successfully via HTTP, but my LUA resident script CANNOT WRITE to these same files.
Files are located at: /user/data/event_definitions.json and /user/data/event_schedules.json
JavaScript reads them successfully via HTTP:
- fetch('/apps/data/event_definitions.json') → Works perfectly
- Files exist and are readable
LUA resident script attempts to write to: /user/data/event_definitions.json
- Result: Permission denied / Cannot open file for writing
WHAT WE'VE TRIED
1. Direct write using io.open(filepath, 'w'):
Result: Returns nil (cannot open file)
2. Added os.execute('chmod 777 /user/data'):
Result: No effect, still cannot write
3. Write to /tmp/ then copy using os.execute('cp /tmp/file.json /user/data/file.json'):
Result: Copy command returns exit code 256 (failure)
4. Write to /tmp/ then cat using os.execute('cat /tmp/file.json > /user/data/file.json'):
Result: Exit code 256 (failure), verification shows file not updated
FTP ACCESS
- When logged in via FTP as user "apps": Can see /user/data/ directory with the JSON files
- When logged in via FTP as user "ftp": Root folder is empty
QUESTION
What is the correct way to make /user/data/ writable by LUA resident scripts?
OR
What is the recommended directory for storing user data files that:
1. Can be written to by LUA scripts
2. Can be read via HTTP by JavaScript (fetch API)
3. Persists across reboots (not /tmp/)
4. Is accessible via FTP for backup purposes
Any guidance would be greatly appreciated!