![]() |
|
Cannot Write to Files from LUA Resident Script - Printable Version +- LogicMachine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Cannot Write to Files from LUA Resident Script (/showthread.php?tid=6214) |
Cannot Write to Files from LUA Resident Script - Intelect - 11.12.2025 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! RE: Cannot Write to Files from LUA Resident Script - AEK - 12.12.2025 (11.12.2025, 16:08)Intelect Wrote: Hello, Code: str = '123123123'this will write file to local ftp server, access with user ftp RE: Cannot Write to Files from LUA Resident Script - admin - 12.12.2025 Correct path is /www/user/ not /user/. But a better approach is to put data into storage and use .lp files for fetching it. |