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: Running scripts on Windows from Oracle stored procedures

Re: Running scripts on Windows from Oracle stored procedures

From: Phil Jones <phillipjones_at_gmail.com>
Date: Thu, 26 Jan 2006 10:33:31 +0000
Message-ID: <b64a80d00601260233v79c68352j@mail.gmail.com>


Hi,

You can do this using a Java stored procedure. Don't have the time to write a full class for you, but you'll want to begin with something like this:

CREATE OR REPLACE JAVA SOURCE NAMED "execProg" AS import java.io.*;
public class execProg {
  public static void execute(String prog) {     try {

      String[] cmd = new String[2];
      cmd[0] = "c:\\windows\\system32\\cmd.exe";
      cmd[1] = prog;
      final Process proc = Runtime.getRuntime().exec(cmd);
   }
   catch (Exception e) {}
  }
};

.. then you'll need to add a grant to allow the user to execute cmd.exe:

BEGIN
dbms_java.grant_permission('USERNAME','java.io.FilePermission','c:\\windows\\system32\\cmd.exe','execute'); END;
/

Hope this is a good starting point for you. (Note: Completely untested!!)

Cheers,

Phil

On 26/01/06, John Dunn <jdunn_at_sefas.com> wrote:
> I have a requirement to run some scripts on Windows from Oracle 9 stored
> procedures. The stored procedures are written in PL/SQL although Java is an
> option.
> The scripts will be .bat files or perl or python programs.
>
> What is the best way to execute these from a stored procedure?. Oracle
> database platform on Windows will be Oracle 9 or 10.
>
>
>
> 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-l
>
>
>

--
http://www.freelists.org/webpage/oracle-l
Received on Thu Jan 26 2006 - 04:33:31 CST

Original text of this message

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