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

Home -> Community -> Usenet -> c.d.o.server -> DOS Host Call via Java SP

DOS Host Call via Java SP

From: Housen <rchin_at_panix.com>
Date: Tue, 13 Apr 2004 14:33:46 -0400
Message-ID: <c5hbod$fsm$1@reader2.panix.com>


Please help me out..thanks

The code below worked fine under *nix (9i) where instead of "c:/winnt/system32/cmd", I had "/bin/sh". But under 8i/W2K, it's not carrying out my commands:

CREATE OR REPLACE AND COMPILE
JAVA SOURCE NAMED "Util"
AS
import java.io.*;
import java.lang.*;

public class Util extends Object
{

public static int RunThis(String args)
{

Runtime rt = Runtime.getRuntime();
int rc = -1;

try
{

String[] cmd = {"c:/winnt/system32/cmd", "/c", args}; Process p = Runtime.getRuntime().exec(cmd); rc = p.waitFor();
}
catch (Exception e)
{

e.printStackTrace();
rc = -1;
}
finally
{

return rc;

}
}
}

/

CREATE OR REPLACE
FUNCTION run_host_cmd(p_cmd IN VARCHAR2) RETURN NUMBER AS
LANGUAGE JAVA
NAME 'Util.RunThis(java.lang.String) return integer'; /

CREATE OR REPLACE PROCEDURE RC(p_cmd IN VARCHAR2) AS
x NUMBER;
BEGIN
x := run_host_cmd(p_cmd);
END;
/

SQL> exec rc('del C:\temp\foo.pdf');

PL/SQL procedure successfully completed

Received on Tue Apr 13 2004 - 13:33:46 CDT

Original text of this message

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