Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Call unix command in package

Re: Call unix command in package

From: <scjonson_at_fyiowa.infi.net>
Date: Fri, 01 Oct 1999 12:41:34 GMT
Message-ID: <7t2a5s$raf$1@nnrp1.deja.com>


You can use a pipe to do what you're talking about. I got this from Thomas Kyte:

This creates a pipe with the name of the user but you can use any name you want. Goes on the database:
procedure host( cmd in varchar2 ) is

    status number;
begin

    dbms_pipe.pack_message( cmd );
    status := dbms_pipe.send_message( UPPER(user) );     IF ( status != 0 ) THEN
      raise_application_error( -20001, 'Pipe error' );     END IF;
end;

This is running from unix and is reading from the pipe and will execute whatever it finds:



#!/bin/csh -f
sqlplus user/pass_at_xxx <<"EOF" | grep '^#' | sed 's/^.//' > tmp.csh

set serveroutput on
declare
  status number;
  command varchar2(255);
begin
  status := dbms_pipe.receive_message( 'pipename');   if ( status != 0 ) then
    dbms_output.put_line( '#exit' );
  else

    dbms_pipe.unpack_message( command );
    dbms_output.put_line( '##!/bin/csh -f' );
    dbms_output.put_line( '#' || command );
    dbms_output.put_line( '#exec msg');
  end if;
end;
/

spool off
"EOF" chmod 777 tmp.csh
exec tmp.csh


Hope this helps

Steve J.

In article <37F37D85.6BD324C6_at_poboxes.com>,   KC <kcheung_at_poboxes.com> wrote:
> Hi all,
>
> Is it possible to call unix command in stored procs or packages?
> Cos' we want to implement a mail function to alert users for any
records
> found in a exception table.
>
> Thanks,
> Kevin
>
>

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Fri Oct 01 1999 - 07:41:34 CDT

Original text of this message

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