Delete file in LINUX
Hello!
Trying to delete txt file in folder: /tmp/test
set sc = ##class(%File).Delete("/tmp/test/test1.txt", .ret)
ret=-13
How I can delete file in Lunix system?
Comments
Hello Token,
are you sure file exists and you have right permission to remove the file?
Tipically err 13 on Unix is related to bad permissions
If your goal is to delete this file one time you can do it with one of theses methods :
You can delete the file by using terminal : (the sudo command set you with all privileges on files)
sudo rm /tmp/test/test1.txtOr from an Irii terminal
!sudo rm /tmp/test/test1.txtIf not can you tell me how you create it, and give the result of this command ?
ls /tmp/test.txt -lhor (in Iris terminal
!ls /tmp/test.txt -lhls /tmp/test.txt -lh
-rwxrwxrwx 1 r00028881 r00028881 8 Jan 1109:56 /tmp/test/test1.txtHello!
The result.
Hello Token,
this cannot be the output for your environment.
You are asking (with ls /tmp/test.txt -lh) to show the file or directory named test.txt in the /tmp folder.
As the result is-rwxrwxrwx 1 r00028881 r00028881 8 Jan 11 09:56 /tmp/test/test1.txt
it cannot be the answer for the previous command.
So, you should execute those commands:
ls -lad /tmp/test/test1.txt
ls -lad /tmp/test
ls -lad /tmp
Copy and paste the output so we can understand better the folders content.
Regards
Ambrogio
hello!
ls -lad /tmp/test/test1.txt
-rwxrwxrwx 1 r00028881 r00028881 8 Jan 11 09:56 /tmp/test/test1.txt
ls -lad /tmp/test
drwxrwxr-x 2 r00028881 r00028881 22 Jan 11 10:22 /tmp/test
ls -lad /tmp
drwxrwxrwt 11 root root 269 Jan 12 15:44 /tmp
Good,
so the folder test under tmp is not writable by all. If your script runs under different user and goup (not r00028881) the file could be read and seen but not removed.
You can try to chmod 777 /tmp/test in order to understand if this is the problem.
If you can remove the file after the chmod you must understand who is creating the test folder under /tmp or who is running the script that is unable to remove the file.
Regards
Ambrogio
Thank you Ambrogio!