Question
· Jan 11

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?

Product version: Caché 2017.1
$ZV: "Cache for UNIX (Red Hat Enterprise Linux for x86-64) 2017.2.2 (Build 867_4_20165U) Mon Aug 17 2020 11:28:28 EDT"
Discussion (7)1
Log in or sign up to continue

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.txt

Or from an Irii terminal

!sudo rm /tmp/test/test1.txt

If not can you tell me how you create it, and give the result of this command ?

ls /tmp/test.txt -lh

or (in Iris terminal 

!ls /tmp/test.txt -lh

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

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