Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Problem with java function

RE: Problem with java function

From: John Dunn <john.dunn_at_sefas.co.uk>
Date: Fri, 6 Feb 2004 12:06:16 -0000
Message-ID: <A05E0089719FD311911400A0249EE7E5B9587C@guest-wv-50.ripe.net>


The funtion returns 0, but the echo has not worked, i.e the output file does not exist.

The touch command creates the output file Ok

John

-----Original Message-----
From: Naveen, Nahata (IE10) [mailto:Naveen.Nahata_at_honeywell.com] Sent: 06 February 2004 11:56
To: oracle-l_at_freelists.org
Subject: RE: Problem with java function

What error are you getting?

Regards
Naveen

>-----Original Message-----
>From: John Dunn [mailto:john.dunn_at_sefas.co.uk]
>Sent: Friday, February 06, 2004 5:09 PM
>To: new oracle list
>Subject: Problem with java function
>
>
>I have a problem with a java function that I use to run unix commands.
>It works OK for most commands(for example touch works fine),
>but I am having
>problem with the echo command.
>I am wondering whether the problem is the redirection sign >
>
>
>Plaform is Oracle 9.2 on Solaris but same problem occurs on AIX
>
>Below is the code and the sql script I use to test.
>
>Any thoughts?
>
>---------------------------------------------------------------
>-------------
>--------------------
>
>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; }
>
> } catch (Throwable t) { rc = 3; }
> return(rc);
> }
>}
>/
>
>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';
>/
>
>
>
>
>sql script to test it
>
>/* example call to unix function */
> set serveroutput on
> VARIABLE retcode NUMBER;
> begin
>--:retcode := function_run_os_command('/usr/bin/echo hello >
>/tmp/testecho');
>:retcode := function_run_os_command('/usr/bin/touch /tmp/testecho');
>
>
>dbms_output.put_line('retcode ' || :retcode);
> end;
>.
>/
>exit
>
>
>
>
>----------------------------------------------------------------
>Please see the official ORACLE-L FAQ: http://www.orafaq.com
>----------------------------------------------------------------
>To unsubscribe send email to: oracle-l-request_at_freelists.org
>put 'unsubscribe' in the subject line.
>--
>Archives are at http://www.freelists.org/archives/oracle-l/
>FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
>-----------------------------------------------------------------
>



Please see the official ORACLE-L FAQ: http://www.orafaq.com

To unsubscribe send email to: oracle-l-request_at_freelists.org put 'unsubscribe' in the subject line.
--
Archives are at http://www.freelists.org/archives/oracle-l/
FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------
----------------------------------------------------------------
Please see the official ORACLE-L FAQ: http://www.orafaq.com
----------------------------------------------------------------
To unsubscribe send email to:  oracle-l-request_at_freelists.org
put 'unsubscribe' in the subject line.
--
Archives are at http://www.freelists.org/archives/oracle-l/
FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------
Received on Fri Feb 06 2004 - 06:06:16 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US