Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Java Permissions Oracle 10
Can anyone please assist me with java permissions when running a java
function in Oracle 10 on linux?
I use the following java code to run unix commands.
It works fine provided the command does not write a file. However if the command trys to write a file my code returns a return code of 127
Is this a java permissions issue? There should be no linux file pernmission issues as I can run the command Ok from the command line as oracle
What java permissions do I need to grant?
CREATE or REPLACE FUNCTION function_run_os_command(Command IN STRING)
RETURN NUMBER IS
LANGUAGE JAVA
NAME 'function_os_command.Run(java.lang.String) return integer';
/
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "function_os_command" AS
import java.io.*;
import java.util.*;
public class function_os_command
{
public static int Run(String Command)
{
int rc = 0;
try
{
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(Command);
try {
rc = p.waitFor(); } catch (InterruptedException intexc) { rc = 2;}
rt.gc();
} catch (Throwable t) { rc = 3; t.printStackTrace();}
return(rc);
}
}
/
I use the following sqlplus to test it.
set serveroutput on
VARIABLE retcode NUMBER;
begin
John Dunn
Product Consultant
Direct Dial +44 (0) 117 373 6122
Sefas Innovation Ltd, CityPoint, Temple Gate, Bristol BS1 6PL, UK.
Tel: +44(0) 117 373 6114
Fax: +44 (0) 117 373 6115
www.sefas.com
-- http://www.freelists.org/webpage/oracle-lReceived on Tue Aug 22 2006 - 05:10:49 CDT
- application/ms-tnef attachment: winmail.dat
![]() |
![]() |