DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: Run a Unix Script from Oracle???

  1. #1
    Join Date
    Jan 2001
    Posts
    515
    Can you kick off a unix script from inside a PL/SQL program??

  2. #2
    Join Date
    Jun 2001
    Location
    Helsinki. Finland
    Posts
    3,938
    Yes.

    1. Configure your listener properly. If you don't now how, ask you DBA. If he doesn't know ask here.

    2. Same with tnsnames.ora

    3. Build shared libraries for use in external procedures:

    In 8.0.X,

    $ make -f demo_rdbms.mk extproc_nocallback \
    SHARED_LIBNAME=shell.so OBJS=shell.o

    In 8.1.X,

    $ make -f demo_rdbms.mk extproc_no_context \
    SHARED_LIBNAME=shell.so OBJS=shell.o


    4. Define the libraries:

    CREATE LIBRARY shell_lib is '/u11/home/lsupport/proc/shell.so';
    /

    5. The PL/SQL should look something like:

    create or replace procedure ala_bala(x in char)
    as external
    name "name"
    library shell_lib
    language C
    parameters (x string);
    /


  3. #3
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447
    you have 2 options, use external C procedure interacting with dbms_pipe, or Java Stored procedure
    There is a third one with CSH and DBMS_PIPE, for that you have to search on Asktom.oracle.com

  4. #4
    Join Date
    Jan 2001
    Posts
    515

    What about this?

    I was thinking that I could create a procedure that excepts the script name as a in parameter,/u04/mywork/test.sh, and then using dynamic sql I would create a string that would host out of oracle. "host /u04/mywork/test.sh" and then execute it. I haven't tested it yet but I would think that if oracle had rights to that directory and script that it should work.

  5. #5
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447
    if you use dbms_output you will have a problem, if you build several commands they will executed all at the end, if you run it at runtime it wont work because host is a sql*plus command not sql

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width