RE: Java Permissions Oracle 10 : updated

  • From: "John Dunn" <jdunn@xxxxxxxxx>
  • To: "'John Dunn'" <jdunn@xxxxxxxxx>, <oracle-l@xxxxxxxxxxxxx>
  • Date: Tue, 22 Aug 2006 11:14:02 +0100

> 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
>   -- This works
>   :retcode := function_run_os_command('/bin/sleep 10');
>   -- This return 127
>   :retcode := function_run_os_command('/bin/env > /tmp/envlog');
>   dbms_output.put_line('retcode = ' || :retcode);
>   end;
>  
> 
> 
> 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
> 
> 
> 

Other related posts: