call_shell_java.sql
First a small Java program that taker a string as a parameter and executes it as an os-command import java.lang.Runtime; import java.lang.Process; public class Commands extends Object { /** * Constructor */ public Commands() { } // On NT the command should be like this "cmd /c del c:\temp\readme.txt" // exec execute('cmd /c del c:\temp\readme.txt'); public static void execute (String cmd ) { try { Process p = Runtime.getRuntime().exec(cmd); try { p.waitFor(); } catch (java.lang.InterruptedException intex ) { intex.printStackTrace(); } System.out.println("Return = "+ p.exitValue()); System.out.println(" Done ..."); } catch ( java.io.IOException iox) { iox.printStackTrace(); } } } ===================end of java ==== Use loadjava to load it into the database and create a pl/sql wrapper around the java code. See the manual about loadjava details. Log in to sqlplus as SYSTEM and create a role for this purpose e.g. 'JAVA_ROLE' and exec the following as SYSTEM or SYS to make sure the user has the the needed privs. dbms_java.grant_permission('JAVA_ROLE','SYS:java.io.FilePermission','<<ALL FILES>>','read,write,execute,delete'); dbms_java.grant_permission('JAVA_ROLE','SYS:java.lang.RuntimePermission','writeFileDescriptor',null); dbms_java.grant_permission('JAVA_ROLE','SYS:java.lang.RuntimePermission','readFileDescriptor',null);