9

Could you please let me know how to call a shell script from PLSQL program?

4 Answers 4

7

You have a couple of options available:

  1. Invoke a Java method from within a PL/SQL wrapper.
  2. Call a C program as an external procedure from within PL/SQL.
  3. Use the new DBMS_SCHEDULER package.

Here's a link with INFO on them.

Sign up to request clarification or add additional context in comments.

2 Comments

In the second solution, is there any other direct way.
@ChandraBhushan - what do you mean by "there any other direct way"?
3

And a forth way (on top of Pablo's) dbms_pipe


http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:16212348050

In Oracle7.0 and up, we can use dbms_pipes to talk to a daemon running outside the database. Here is a simple example that uses sqlplus to be the daemon:

create or replace procedure host( cmd in varchar2 )
as
    status number;
begin
    dbms_pipe.pack_message( cmd );
    status := dbms_pipe.send_message( 'HOST_PIPE' );
    if ( status <> 0 ) then raise_application_error( -20001, 'Pipe error' );
    end if;
end;
/

Comments

2

Invoking a shell script from PL/SQL using DBMS_SCHEDULER: Please find the link below
http://www.dba-oracle.com/t_execute_shell_script_plsql_procedure.htm

Comments

1

Not listed above, but still applicable: C Code direct library from PL/SQL from Ask Tom. Obviously it would be an execution of a C Wrapper to call out to the Shell script.

1 Comment

Tom's example is actually just another sample of method #2 i.e. an external procedure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.