Executing external programs from PL/SQL?

Hi All,
Is it possible to execute external
programs (i.e. shell scripts, or
perl scripts) from a stored procedure
or trigger?
I know that typically it is the other
way around, but hey try telling that
to my boss.
Thanks

you cant execute any operating system commands from plsql
procedures. but you can achieve result by using either java
stored procedure or pro*C program .
Suresh Vemulapalli

Similar Messages

  • Calling external program from PL/SQL

    Does anyone know whether it's possible to call an external program living outside of Oracle from PL/SQl eg. a from a stored procedure?
    Specifically i want to call back into my java appserver (ejb server) when a trigger/stored proc. is executed.
    The call does not have to be synchronous, some sort of queue will do - eg JMS??
    Any help greatly appreciated.
    null

    Hi
    Which version of oracle you are using.
    If it 8i, you can use external procedures/libraries. REfer to ORacle PLSQL documentation.
    If you are using Oracle 7+ you can use dbms pipes to post your command string and a cron job to read the pipe and execute the string.
    An alternate ugly way is to write to a file and some process reading the file at a regular interval.
    HTH
    Arvind Balaraman

  • Pocket PC -Problem executing external program from java

    Hi,
    I'm developing an application on Dell Axim x51 PDA. I am using mysaifu jvm. The application needs to execute an external program (.exe) for which I'm using the Runtime class.
    I get java.io.IOException: The system cannot find the file specified.
    I have verified that the file exists. ( i used File class to check if the file exists)
    here's the part of code :
    Runtime rt = Runtime.getRuntime ();      
    File sktScan = new File("\\My Documents\\RFID\\ScktScan.exe");
    if(sktScan.exists())
    System.out.println("FILE EXISTS");
    String command = sktScan.getAbsolutePath();
    process = rt.exec (command);
    System.out.println("Socket Scan Path is : "+command);

    You have acces to "java.lang.Runtime currentRuntime.exec()" method ? in my case NetBeans IDE dont give me for my compilation with :
              microedition.configuration     CLDC-1.1     
              microedition.profiles     MIDP-2.0

  • Execute external program from java in the same virtual machine

    hello,
    I need some help. here is what i need: i'm developing a test tool and i need to execute the application to be tested from my test tool in the same virtual machine so that i can be able to connect to that application and catch events like clicking and so on.
    problem is that i do not know how to launch the application i want to test in the same virtual machine as the test tool.
    any help would be good,
    thanks

    problem is that i do not know how to launch the
    application i want to test in the same virtual
    machine as the test tool.Just invoke the main class of that application.
    You probably don't want to hear this, but writing a test tool is not easy if you are going to try to catch events etc. It's probably a bit too hard for you if you don't know how to invoke an app within the same VM.
    Kaj

  • How can I execute an external program from within a button's event handler?

    I am using Tomcat ApacheTomcat 6.0.16 with Netbeans 6.1 (with the latest JDK/J2EE)
    I need to execute external programs from an event handler for a button on a JSF page (the program is compiled, and extremely fast compared both to plain java and especially stored procedures written in SQL).
    I tried what I'd do in a standalone program (as shown in the appended code), but it didn't work. Instead I received text saying the program couldn't be found. This error message comes even if I try the Windows command "dir". I thought with 'dir' I'd at least get the contents of the current working directory. :-(
    I can probably get by with cgi on Apache's httpd server (or, I understand tomcat supports cgi, but I have yet to get that to work either), but whatever I do I need to be able to do it from within the button's event handler. And if I resort to cgi, I must be able to maintain session jumping from one server to the other and back.
    So, then, how can I do this?
    Thanks
    Ted
    NB: The programs that I need to run do NOT take input from the user. Rather, my code in the web application processes user selections from selection controls, and a couple field controls, sanitizes the inoputs and places clean, safe data in a MySQL database, and then the external program I need to run gets safe data from the database, does some heavy duty number crunching, and puts the output data into the database. They are well insulated from mischeif.
    NB: In the following array_function_test.pl was placed in the same folder as the web application's jsp pages, (and I'd tried WEB-INF - with the same result), and I DID see the file in the application's war file.
            try {
                java.lang.ProcessBuilder pn = new java.lang.ProcessBuilder("array_function_test.pl");
                //pn.directory(new java.io.File("K:\\work"));
                java.lang.Process pr = pn.start();
                java.io.BufferedInputStream bis = (java.io.BufferedInputStream)pr.getInputStream();
                String tmp = new String("");
                byte b[] = new byte[1000];
                int i = 0;
                while (i != -1) {
                    bis.read(b);
                    tmp += new String(b);
                getSelectionsDisplayTextArea().setText(getSelectionsDisplayTextArea().getText() + "\n\n" + tmp);
            } catch (java.io.IOException ex) {
                getSelectionsDisplayTextArea().setText(getSelectionsDisplayTextArea().getText() + "\n\n" + ex.getMessage());
            }

    Hi Fonsi!
    One way to execute an external program is to use the System Exec.vi. You find it in the functions pallet under Communication.
    /Thomas

  • How to call Operating System commands / external programs from within APEX

    Hi,
    Can someone please suggest how to call Operating Systems commands / external programs from within APEX?
    E.g. say I need to run a SQL script on a particular database. SQL script, database name, userid & password everything is available in a table in Oracle. I want to build a utility in APEX where by when I click a button APEX should run the following
    c:\oracle\bin\sqlplusw.exe userud/password@database @script_name.sql
    Any pointers will be greatly appreciated.
    Thanks & Regards,

    Hi Guys,
    I have reviewed the option of using scheduler and javascript and they do satisfy my requirements PARTIALLY. Any calls to operating system commands through these features will be made on the server where APEX is installed.
    However, here what I am looking at is to call operating systems programs on client machine. For example in my APEX application I have constructed the following strings of commands that needs to be run to execute a change request.
    sqlplusw.exe user/password@database @script1.sql
    sqlplusw.exe user/password@database @script2.sql
    sqlplusw.exe user/password@database @script3.sql
    sqlplusw.exe user/password@database @script4.sql
    What I want is to have a button/link on the APEX screen along with these lines so that when I click that link/button this entire line of command gets executed in the same way it would get executed if I copy and paste this command in the command window of windows.
    Believe me, if I am able to achieve what I intend to do, it is going to save a lot of our DBAs time and effort.
    Any help will be greatly appreciated.
    Thanks & Regards,

  • Calling Cobol program from PL/SQL

    What is the caling convention for PL/SQL to call a Cobol program?

    You cannot do it directly from PL/SQL. PL/SQL is.. well, kind of abstract ito the actual platform it runs on. PL/SQL cannot talk directly to operating system. It cannot (itself) do socket calls, file I/O calls, use the printer, etc.
    <p>
    All this has to be done using a lower level implementation library - like UTL_FILE for example that wraps internal C written modules that does file I/O. PL/SQL can call these to do I/O on its behalf. Ditto for wrappers like UTL_TCP and others.
    <p>
    There is no default wrapper for calling external processes from PL/SQL. It can however be done indirectly using the external procedure (EXTPROC) feature, or using Java to do it.
    <p>
    The latter is the easiest. You create a Java stored proc that can access the operating system and run external programs and commands. You punch a big hole in the Oracle Java security to allow this Java stored proc access to the operating system. Next you create a PL/SQL wrapper for this Java proc which then in turn can be called from PL/SQL.
    Just remember that you MUST secure this hole you've punched into Oracle security. If any Oracle user can access this PL/SQL wrapper, they can hack, compromise, trash or simply destroy your entire Oracle account on that server.
    Here is the basic code:
    create or replace and compile Java Source named "OSCommand" as
    -- java:        OS COMMAND
    -- descr:       Executes an Operating System Command using the JAVA RTS
    -- IN parameter:        os command to execute (including fully qualified path names)
    -- OUT parameter:       returncode [\nstring]
    --                      where string a max of 32000 chars of the output of the command
    --                      (note that \n is used as separators in the string)
    --                      returncode=-1   Java RTS error occurred (e.g. command does not exist)
    --                      returncode=255  o/s command failed (e.g. invalid command params)
    import java.io.*;
    import java.lang.*;
    public class OSCommand{
            public static String Run(String Command){
                    Runtime rt = Runtime.getRuntime();
                    int     rc = -1;
                    try{
                            Process p = rt.exec( Command );
                            int bufSize = 32000;
                            int len = 0;
                            byte buffer[] = new byte[bufSize];
                            String s = null;
                            BufferedInputStream bis = new BufferedInputStream( p.getInputStream(), bufSize );
                            len = bis.read( buffer, 0, bufSize );
                            rc = p.waitFor();
                            if ( len != -1 ){
                                    s = new String( buffer, 0, len );
                                    return( s );
                            return( rc+"" );
                    catch (Exception e){
                            e.printStackTrace();
                            return(  "-1\ncommand[" + Command + "]\n" + e.getMessage() );
    show errors
    create or replace function OSexec( cCommand IN string ) return varchar2 is
    -- function:    OS EXEC
    -- descr:       PL/SQL wrapper for the Java OSCOMMAND stored proc
    language        JAVA
    name            'OSCommand.Run(java.lang.String) return java.lang.String';
    show errors
    -- Punching a hole into the Java VM sandbox. The following must be run as
    -- sysdba. Substitute SCOTT with the applicable schema that owns the OSEXEC
    -- and OSCOMMAND stored procs.
    declare
            SCHEMA  varchar2(30) := 'SCOTT';
    begin
            dbms_java.grant_permission(
                    SCHEMA,
                    'SYS:java.io.FilePermission',
                    '<<ALL FILES>>',
                    'execute'
            dbms_java.grant_permission(
                    SCHEMA,
                    'SYS:java.lang.RuntimePermission',
                    'writeFileDescriptor',
            dbms_java.grant_permission(
                    SCHEMA,
                    'SYS:java.lang.RuntimePermission',
                    'readFileDescriptor',
    commit;
    end;
    -- example: running the Unix/Linux date command to get the current date and time
    SQL> select OSexec('/usr/bin/date') as STDOUT from dual;
    STDOUT
    Fri Sep  1 08:09:34 SAST 2006
    1 row selected.
    SQL>Edited by: Billy Verreynne on Sep 4, 2008 6:26 PM to make the code snippet readable with the new Jive forum s/w.

  • I want to submit a concurrent program from pl/sql. Please help me.

    Dear all,
    I want to submit a concurrent program from pl/sql. But I failed. Please help me.
    Detail:
    I create a concurrent program in 'Cash Management, Vision Operations (USA)' responsibility. <strong>And it be submitted success in EBS</strong>.
    Then
    I create a test script in pl/sql. And use 'FND_GLOBAL.APPS_INITIALIZE' to initialize ebs, then use 'FND_REQUEST.SUBMIT_REQUEST' to submit
    the consurrent program, But the procedure aways return <strong>0</strong>.
    I cannot found the reason. Please help me.Thanks.
    <em>Attached informations may describe the problem:
    1.The concurrenct submitted success in EBS.</em>
    request_id = 4750655 (Sorry, I dont know how to add pictures.)
    <em>2.The initialize informations which from SQL</em>.
    SELECT FCR.REQUESTED_BY USER_ID
    ,FCR.RESPONSIBILITY_ID
    ,FCR.RESPONSIBILITY_APPLICATION_ID
    ,FA.APPLICATION_SHORT_NAME
    ,FCP.CONCURRENT_PROGRAM_NAME
    FROM FND_CONCURRENT_REQUESTS FCR
    ,FND_APPLICATION FA
    ,FND_CONCURRENT_PROGRAMS FCP
    WHERE FCR.PROGRAM_APPLICATION_ID = FA.APPLICATION_ID
    AND FCR.CONCURRENT_PROGRAM_ID = FCP.CONCURRENT_PROGRAM_ID
    AND FCR.REQUEST_ID = 4750655;
    Result: user_id = 1318;
    responsibility_id = 50579;
    application_id = 260;
    application_short_name = 'CE';
    program_short_name = 'CALLK009';
    <em>3.The test script code.</em>
    <p>
    -- Created on 2008/10/22 by ERIC
    declare
    -- Local variables here
    Wv_conc_req_id VARCHAR2(10) DEFAULT NULL;
    BEGIN
    FND_GLOBAL.APPS_INITIALIZE(
    1318
    ,50579
    ,260
    Wv_conc_req_id := FND_REQUEST.SUBMIT_REQUEST(
    'CE'
    ,'CALLK009'
    ,NULL
    ,SYSDATE
    ,FALSE
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    DBMS_OUTPUT.PUT_LINE(Wv_conc_req_id);
    COMMIT;
    end;
    <em>4.The concurrent program code.</em>
    create or replace package body CALLTEST is
    PROCEDURE T1(PvO_errbuf OUT VARCHAR2
    ,PvO_retcode OUT VARCHAR2)
    IS
    BEGIN
    FND_FILE.PUT_LINE(fnd_file.log, 'TEST');
    END;
    end CALLTEST;
    </p>

    Can you check from which schema you are executing FND_REQUEST? You can try as follows;
    Connect to your required schema, create a synonym on apps.fnd_request, connect from apps and finally execute grant all on apps.fnd_request to all.
    You can check for relevance from Doc ID: Note:147495.1
    Please do keep in the mind the soultion above should be applied to a test/dev EBS instance first.
    I hope this would be of help.
    Saad

  • How can I run an external program from a PLSQL procedure?

    Is there a package to run an external program from PLSQL? or is there another way to do that?
    thanks.

    here there is an example about how a PL/SQL procedure can
    work with an external C program.
    http://download-east.oracle.com/docs/cd/A87860_01/doc/appdev.817/a76936/dbms_pi2.htm#1003384
    Apart from that you have Java Stored Procedures option
    to carry out your task.
    Java Stored Procedures Developer's Guide Contents / Search / Index / PDF
    http://download-east.oracle.com/docs/cd/B10501_01/java.920/a96659.pdf
    Joel P�rez

  • Call C++ programs from PL/SQL

    Can someone give me an example of how to call C++ programs from PL/SQL ASAP please?
    Thanks
    Chitra

    Hello,
    You can use External Procedure facility of of PL/SQL (Assuming your DB is 8 or 8i)
    Please refer the doc at http://oradoc.photo.net/ora8doc/DOC/server803/A54654_01/10_procs.htm
    James

  • Running an External Program from Batch on Windows Server 2008R2 Failing

    Hi,
    I am trying to run an external program from a batch job and it is failing with this error message:
    Ext. prog.: ERROR: Input redirection is not supported, exiting the process immediately.
    Ext. prog.: External program terminated with exit code 1
    The program I am trying to run is:  timeout
    This command works on the OS: timeout -t 30
    I have setup the step to look like this:
    Under External Program:
    -Name: timeout
    -Parameter: -t 30
    I have also tried:
    -Name: timeout -t -30
    -Parameter:
    I am running ECC 6.04 on top of Windows Server 2008R2 with SQL Server 2008R2. 
    When we were running in Server 2003 on ECC 6.0 I was able to use the Sleep program just fine in the same manner.  I have found out that sleep is not available in server 2008.  It was replaced with timeout.
    After an update to EHP4 and moving to Windows Server 2008R2, Is there any pre-work that needs to be done on the SAP or Windows side before we can run external programs?
    Thank you,
    Neil

    > SAPService<SID> and <SID>ADM both have Administrator rights for the server.
    > That means they should have full access.
    No - this is no more true like that since Windows 2008, it's a bit more complex:
    http://en.wikipedia.org/wiki/User_Account_Control
    > Where would you setup the permission/policy to "interact with the desktop"?
    Add the policy using group policy editor (gpedit.msc)
    Markus

  • How to execute  a program  from another

    Hi, expert
    Sorry for this question, but how can I do to execute a program from another with no parameter.
    I will thanks an answer, it's urgent...
    Regardss,
    mgg
    P.D. Points rewarded.

    Simple,  use the SUBMIT statement.
    SUBMIT zreport and return.
    Regards,
    RIch HEilman

  • Invoke External programs from inside App Server

    hi,
    How can I invoke an external program from a session bean (or from an MDB)?
    Can I use Runtime.exec() directly from a bean?
    If so, are there any security considerations?
    thanks,
    Sundar

    I found this article rather helpful:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Executing *.bat file from PL/SQL

    Is there anyway for Executing *.bat file from PL/SQL ?
    Thanks

    Try here:
    asktom.oracle.com/pls/ask/f?p=4950:8:15427268967155079552::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:952229840241

  • Calling java program from PL/SQL code

    Dear,
    How to develop and call a java program from PL/SQL code?
    What about if this program will call other java programs?

    Perhaps the Java Developer's Guide would be a good place to start
    http://download.oracle.com/docs/cd/B19306_01/java.102/b14187/toc.htm
    Justin

Maybe you are looking for