Calling  Operating system command  from PL/SQL programs

Hi
Is there any way we call the unix shell script from PL/SQL procedure/functions

In 10g, it is possible.
BEGIN
dbms_scheduler.create_job(job_name => 'myjob',
job_type => 'executable',
job_action => '/app/oracle/x.sh',
enabled => TRUE,
auto_drop => TRUE);
END;
SQL> exec dbms_scheduler.run_job('myjob');
Documentation:
http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sched.htm#sthref6596
-aijaz

Similar Messages

  • Calling Operating System Commands from PL/SQL using java

    Calling Operating System Commands from PL/SQL - The Java Way
    wlth help of given thread link,
    Calling OS Commands from Plsql
    but i had user privilege problem
    Declare
    x Varchar2(2000);
    Begin
    x := OSCommand_Run('/tmp/sri/GROUP_ho.sh');
    DBMS_OUTPUT.Put_Line(x);
    End;
    o/p;
    can't exec: /tmp/sri/GROUP_ho.sh lacks user privilege
    i done the grant privillage also
    part
    dbms_java.grant_permission('abcd', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
    dbms_java.grant_permission('abcd', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
    dbms_java.grant_permission('
    abcd', 'SYS:java.io.FilePermission','<<ALL FILES>>', 'execute');
    again
    get
    can't exec: /tmp/sri/GROUP_ho.sh lacks user privilege
    same error;

    Process management at the OS level should prevent execution continuing in the calling code until the command has completed (either successfully or with error).
    If the low level java code were to spawn child process threads then execution could continue, but I'm guessing the Java function your talking about doesn't do that and just calls the operating system to execute the command and waits for the returning code to come back.

  • How to: execute operating system commands from PL/SQL

    System: IBM pSeries AIX
    Oracle: 11g Enterprise
    Is there a quick way to execute operating system commands from PL/SQL?
    Without creating a JAVA class....
    I need to execute a Loader script.
    I want to do this from within PL/SQL.
    I need to to do 4 things.
    Three require SQL scripts.
    The fourth is SQL*Loader.
    The usual way is with a UNIX script calling 3 SQL scripts and one Loader control file.
    Is there way to do all this from within ONE PL/SQL SCRIPT ??
    Just let me know.

    Is there a quick way to execute operating system commands from PL/SQL?
    NO
    Without creating a JAVA class....
    I need to execute a Loader script.
    I want to do this from within PL/SQL.
    WHY ON EARTH, such action will create a new connection and become a resource hog?
    I need to to do 4 things.
    Three require SQL scripts.
    The fourth is SQL*Loader.
    The usual way is with a UNIX script calling 3 SQL scripts and one Loader control file.
    Which is perfect for the purpose.
    Is there way to do all this from within ONE PL/SQL SCRIPT ??
    Just let me know.
    NO, there is NOT. Nor should there be. Why create unstable ineffcient Mickey Mouse systems, glued together by hacking?
    Sybrand Bakker
    Senior Oracle DBA

  • 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,

  • Executing a Operating System command from Stored Procedure ??

    I want to execute a Operating System command from a PL/SQL Stored Procedure, can anyone suggest me how can I do this ??
    I am on Sun-Solaris with Oracle 8.1.7 database.
    Please do email me at [email protected]
    Thanks in Advance,
    Ramesh L.

    Are you using a webserver? If so, you could make your operating system script into a CGI program, then execute it from pl/sql using utl_http.request.

  • Is it possible to call operating system command after file receive?

    Hi expert,
    I'm trying to call operating system command after file receive comm.channel receive a txt file.
    operating system command uses txt file name as parameter.
    Is it possible? How?
    Thanks.

    Hi,
    It should be possible, actually we have two options that are
    1.RUN OS command before message processing
    2.RUN OS command after message processing.
    So you can give the commands in the RUN OS command after message processing.
    Check this links for more info
    http://wiki.sdn.sap.com/wiki/display/XI/SAP%20XI%20File%20Adapter%20OS%20Command%20Line%20Feature
    http://help.sap.com/saphelp_nwpi71/helpdata/en/44/556cb799c93677e10000000a114a6b/content.htm
    http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417200)ID1690747750DB11724434094963199241End?blog=/pub/wlg/10392
    Regards
    Ramesh

  • Call operating system services from Jdeveloper

    How can i call operating system services from Jdeveloper ?
    null

    We do not use JDeveloper but use external procedures/routines called from the database. Then you can call a database procedure to an operating system task.
    Linda

  • How to execute Operating System commands from Stored procedure.

    Any help on how to execute Operating System commands from stored procedures will be appreciated.
    Nanditha.

    Search the forums for 'External Procedure' and you will find example code that has been posted before.

  • How to call operating system commands?

    Can we call OS commands from JAVA?
    I am trying to call lpr/lp commands from JAVA.
    Can anybody guide me where to search for this information.
    Thanks in advance
    Srini

    Thanks for you all for this information. I will try this....Your information greatly helped me to go forward...

  • How can I pass system commands from a java program? Urgent!

    hi,
    I have been trying this out since a long time. How do I send system commands to command.com or cmd.exe from a java program and an output of the executed command back to the java application.
    If u have any idea, or have any information about the kind os application reply back.
    Thanks
    Deepa Datar

    This is the code which I tried, but it displays only the title of MS-DOS, something like " Microsoft Corp...etc ". But doesn't take any input, and the subprocess(cmd.exe) hangs.
    import java.io.*;
    public class cmddemo2
    public static void main(String arg[])
    try
    System.out.println("cmd");
    Process p=Runtime.getRuntime().exec("cmd.exe");
    DataInputStream din=new DataInputStream(p.getInputStream());
    DataOutputStream dout=new DataOutputStream(p.getOutputStream());
    System.out.println("after streams");
    String s;
    dout.writeChars("type cmddemo2.java");
    while((s=din.readLine())!="\n")
    System.out.println(s);
    dout.writeChars("dir");
    String s1;
    while((s1=din.readLine())!="\n")
    System.out.println(s1);
    System.out.println("over");
    catch(Exception e)
    { System.out.println("Exception : "+e);

  • How to issue a SQL*Plus command from PL/SQL program?

    Thanks.

    You can't issue a SQL*PLus command from a PL/SQL program. If you can tell us more about what you are trying to do, perhaps we can offer a substitute.

  • Calling an unix command from a java program which runs on windows

    Hello All
    I have an Java Application which is run on windows server (I)
    I have another Sun Server (II)
    I want to call an unix command on server(II) from java application which is on server(I)
    I am using Samba Server in order to share files between Windows Server and Unix Server
    Can I use samba in order to call command
    or is there any way to open an telnet session within java application
    I will be grateful if you give me some suggestion on this issue
    Regards
    BEKIR BALCIK
    J2EE Application Developer
    Argela Technologies ...

    cross post
    http://forum.java.sun.com/thread.jspa?threadID=624601&messageID=3553626#3553626

  • O/s commands from PL/SQL

    hi all..
    i want to execute operating system commands from PL/SQL..
    particulary imp command....
    i have used the f/wg approach but while i execute the imp command it does not responds me any output..
    I have to kill the process from o/s.
    prodn is my user
    --AS SYS user
    begin
    dbms_java.grant_permission( 'PRODN',
    'SYS:java.io.FilePermission',
    '/oracle/product/9.2.0/bin/imp',
    'execute' );
    dbms_java.grant_permission
    ('PRODN',
    'java.lang.RuntimePermission',
    'writeFileDescriptor' );
    end;
    ---------------------------------AS PRODN user
    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
    Process p = rt.exec(args);
    int bufSize = 4096;
    BufferedInputStream bis = new BufferedInputStream(p.getInputStream(),
    bufSize);
    int len;
    byte buffer[] = new byte[bufSize];
    // Echo back what the program spit out
    while ((len = bis.read(buffer, 0, bufSize)) != -1)
    System.out.write(buffer, 0, len);
    rc = p.waitFor();
    catch (Exception e)
    e.printStackTrace();
    rc = -1;
    finally
    return rc;
    create or replace
    function RUN_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_cmd(p_cmd);
    end;
    i executed the command as follows in sql>
    BEGIN
    rc('/oracle/product/9.2.0/bin/imp tim/tim file=/home/oracle/vas4359.dmp log
    =log1.log');
    END;
    it runs fine creates log1.log in / home/oracle but there is no output in
    log1.log file.
    I have to kill the process as follows after which sql> displays me :
    "PL/SQL procedure successfully completed."
    [oracle@msebdb oracle]$ ps aux|grep imp
    oracle 20052 0.0 0.2 12732 4328 ? S 11:57 0:00 /oracle/product/
    .2.0/bin/imp file=/home/oracle/vas4359.dmp log=log1.log
    oracle 20102 0.0 0.0 3692 652 pts/2 S 12:03 0:00 grep imp
    Note:There is no tim user.. i just want to get error in my log file..
    my further steps are to read this log file and send email/notifications to users.
    my main program is as f/ws:
    /*imp and check log file*/
    create or replace procedure abc
    as
    v_exists boolean;
    v_exists_log boolean;
    ex_open BOOLEAN;
    flen NUMBER;
    bsize NUMBER;
    vInHandle_open utl_file.file_type;
    vInHandle_open_log utl_file.file_type;
    v_filelog utl_file.file_type;
    v_fl utl_file.file_type;
    v_pth varchar2(60);
    v_fnm varchar2(60);
    v_file_exists varchar2(60);
    v_logline varchar2(30) ;
    v_search varchar2(30) :='ORA-';
    vNewLine VARCHAR2(32767);
    cursor c_fname is
    select full_pth ,f_name from upld_file_t where f_name in
    (select f_name from tbl_file_nm where typ_file='D' AND DEL_FLG='N');
    BEGIN
    for v_sec in c_fname
    loop
    utl_file.fgetattr(LOCATION=>'ORALOAD',
    FILENAME=>v_sec.f_name,
    FEXISTS=>v_exists,
    FILE_LENGTH=> flen,
    BLOCK_SIZE=>bsize);
    if v_exists
    THEN
    dbms_output.put_line('File Exists' || v_sec.f_name);
    v_file_exists:=v_sec.f_name;
    --dbms_output.put_line('v_file_exists ' || v_file_exists);
    dbms_output.put_line('File Length: ' || TO_CHAR(flen));
    dbms_output.put_line('Block Size: ' || TO_CHAR(bsize));
    dbms_output.put_line(' before file open');
    vInHandle_open := utl_file.fopen('ORALOAD',v_sec.f_name,'R',32767);
    -- dbms_output.put_line(' after file open');
    -- do whater with teh file data
    v_fl:=utl_file.fopen('ORALOAD','v_sec.f_name','W');
    dbms_output.put_line('v_sec.f_name');
    IF utl_file.is_open(vInHandle_open)
    THEN
    /*if log file exists..*/
    utl_file.fgetattr(LOCATION=>'ORALOAD',
    FILENAME=>v_sec.f_name||'.log',
    FEXISTS=>v_exists_log,
    FILE_LENGTH=> flen,
    BLOCK_SIZE=>bsize);
    if v_exists_log
    then
    dbms_output.put_line('file' ||v_sec.f_name||'.log');
    v_filelog :=utl_file.fopen('ORALOAD',v_sec.f_name||'.log','W',32767);
    LOOP
    BEGIN
    UTL_FILE.PUT(v_filelog,'ORA-');
    exit;
    END;
    END LOOP;
    else
    dbms_output.put_line('File not found' || v_sec.f_name);
    END IF;
    UTL_FILE.fclose(v_filelog);
    dbms_output.put_line('Closed File ' || v_sec.f_name|| '.log');
    END IF;
    /*imp THE FILE and read log file*/
    utl_file.fgetattr(LOCATION=>'ORALOAD',
    FILENAME=>v_sec.f_name||'.log',
    FEXISTS=>v_exists_log,
    FILE_LENGTH=> flen,
    BLOCK_SIZE=>bsize);
    if v_exists_log
    then
    dbms_output.put_line('file' ||v_sec.f_name||'.log');
    v_filelog :=utl_file.fopen('ORALOAD',v_sec.f_name||'.log','R',32767);
    LOOP
    BEGIN
    UTL_FILE.get_line(v_filelog,v_logline);
    if v_logline = v_search then
    dbms_output.put_line(v_logline);
    end if;
    UTL_FILE.fclose(v_filelog);
    dbms_output.put_line('Closed File ' || v_sec.f_name|| '.log');
    exit;
    END;
    END LOOP;
    else
    dbms_output.put_line('File not found' || v_sec.f_name);
    END IF;
    END IF;
    END LOOP;
    --close the curosr .. check this
    EXCEPTION
    WHEN UTL_FILE.ACCESS_DENIED THEN
    DBMS_OUTPUT.PUT_LINE('No Access!!!');
    when others then
    dbms_output.put_line('ERROR (open_file) => '||sqlcode);
    dbms_output.put_line('MSG (open_file) => '||sqlerrm);
    end;

    Hi,
    You might have better luck in the PL/SQL or Java forums. They are located here:
    PL/SQL: PL/SQL
    Java: http://forums.oracle.com/forums/forum.jsp?forum=99
    Good luck,
    Mark

  • OS command from PL/SQL code

    Is there any way of running on OS (Operating System) command from SQL or PL/SQL. i.e. calling an executable from a trigger.

    Is there any way of running on OS (Operating System) command from >SQL or PL/SQL. i.e. calling an executable from a trigger. Ashis,
    Here's an example of a simple piece of Java you can create using SQL*Plus:
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "RuntimeExample" AS public class RuntimeExample {
    public static String runNotepad() {
    String returnValue = null;
    Runtime r = Runtime.getRuntime();
    try {
         Process p = r.exec("notepad.exe");
         returnValue = p.toString();
         } catch (Exception e) {
              System.out.println("Exception calling Runtime.exec()->" + e);
         /* You can get creative here and
         1) Use p.waitFor() to block while the process is running,
         2) Send the command to be executed as a parameter to the method, etc. */
         return returnValue;
    CREATE OR REPLACE FUNCTION runNotepad RETURN VARCHAR2 IS
    LANGUAGE JAVA NAME 'RuntimeExample.runNotepad() return java.lang.String';
    DECLARE
    my_varchar2 VARCHAR2(64);
    BEGIN
    my_varchar2 := runnotepad;
    DBMS_OUTPUT.PUT_LINE(my_varchar2);
    END;
    Hope this helps,
    -Dan
    http://www.compuware.com/products/numega/dbpartner/dbpordebug.htm
    Debug Java in the Oracle Database

  • Executing Operating system commands in ABAP

    Hi
    I want to execute a unix operating system command in an ABAP program. I remember seeing code which executes an operating system command. Could any please let me know about that code?
    Thank You.
    Eswar

    Hi,
    you can try something like this.
    data:cmd(254) type c.
    data: RESULT(255) OCCURS 100 WITH HEADER LINE.
                cmd = 'ls'.
    ** Execute command
      REFRESH RESULT.
      CALL 'SYSTEM' ID 'COMMAND' FIELD CMD
                    ID 'TAB'     FIELD RESULT-*SYS*.
    Kostas

Maybe you are looking for

  • Hp2509m goes black too fast to use any of the fixes

    I have read, and tried to use, many of the previous forum answwers regarding an HP monitor screen going black.  For example resetting the MENU to FACTORY DEFAULT; correcting OCD display errors; power-cycling; tenacity and patience with repeatedly pre

  • View PDF in IE10 Browser (windows 8)

    Is there a way to click a link for a pdf and view it in a new tab on the browser?  Within windows 7 it worked fine, but I am not finding how to do it in windows 8, either the new metro browser or the desktop browser. It will only open PDFs in Adobe R

  • EQ1 Error Message on Loading Premiere Pro 5.0!

    I have CS5 on a Mac.  This morning, I received an error message halfway through loading Premiere Pro.  The message read, "EQ1 - could not open bin file."  The only option is to click "OK", followed by an option to report the problem or reload the pro

  • Trying to use Dynamic Action with button - no #BUTTON_ID#

    I saw this post: Issue with apex  dynamic action and I'm having exactly the same issue. I'm using the Blue and Tan Theme and the button's "normal template" looks like the following: <table class="t2Button" cellspacing="0" cellpadding="0" border="0" 

  • How to make an Arch Linux Distribution Installer?

    I have made a customized distribution of Arch Linux in vmware. I now need to make its installer for deployment. How can I do it? I have tried Archiso, but it makes new work dir and downloads archlinux again. I want to use the current installed and mo