Using the stored procedure called "rc" (see attached code), I am able to execute Unix commands from PL/SQL, for example:
SQL> exec rc ('touch /home/sde20/WORK_DIR/text_
With the previous command, I can create an empty text file in the Unix directory /home/sde20/WORK_DIR
Well, of course I can also use the rm command to remove files from Unix, and here is the problem!
Please suppose that the Unix user related to Oracle is called oracle10; in the previous example, the text file has the following permissions:
-rw-r--r-- 1 sde20 users 463538 Oct 18 18:20 00203C_17062007_1113_Aggre
-rw-r--r-- 1 sde20 users 463538 Oct 18 18:20 00203C_17062008_1113_Aggre
-rw-r--r-- 1 sde20 users 463538 Oct 18 18:20 00202E_17062008_1116_Aggre
-rw-r--r-- 1 sde20 users 463538 Oct 18 18:20 00202F_17102008_2359_Aggre
-rw-r--r-- 1 sde20 users 463538 Oct 18 18:20 00202F_17102008_2259_Aggre
-rw-r--r-- 1 sde20 users 463538 Oct 18 18:20 00202F_17102008_2159_Aggre
-rw-rw-rw- 1 oracle10 users 0 Oct 20 13:54 text_test_file.txt
You can see that the file called text_test_file.txt has rw-rw-rw permissions, and oracle10 is the owner.
I have problems to delete the OTHER files, owned by sde20 Unix user.
I tried with:
exec rc ('touch /home/sde20/WORK_DIR/00202
in order to empty them, without success: the files whose owner is different from oracle10, remain unchanged :-(
How can I fix this?
Please note that the files owned by sde20 user have 500Kbytes dimension, so I would like to avoid the classical disk full error, or over quota error.
I should be grateful with 500 points, to the best suggestion to solve this problem.
CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED NE."Util" as import java.io.*;
public class Util extends Object
public static int RunThis(String args)
Runtime rt = Runtime.getRuntime();
int rc = -1;
Process p = rt.exec(args);
int bufSize = 4096;
BufferedInputStream bis =
new BufferedInputStream(p.getInputStream(), bufSize);
byte buffer = new byte[bufSize];
// Echo back what the program spit out
while ((len = bis.read(buffer, 0, bufSize)) != -1)
System.out.write(buffer, 0, len);
rc = p.waitFor();
catch (Exception e)
rc = -1;
CREATE OR REPLACE FUNCTION ne.run_cmd (p_cmd IN VARCHAR2)
NAME 'Util.RunThis(java.lang.String) return integer';
CREATE OR REPLACE PROCEDURE ne.rc (p_cmd IN VARCHAR2)
x := run_cmd (p_cmd);