Re: How to call shell script from PL/SQL ?.

From: <andy_kam_at_ctil.com>
Date: 2000/05/11
Message-ID: <8fectt$ubi$1_at_nnrp1.deja.com>#1/1


I've written a PL/SQL which calls an external store proc in written in Java. I test it in SQL*PLUS with a test.sql


SQL> set serveroutput on;
SQL>
SQL> begin
  2     er.sp_er_buildfile('andy.txt');

  3 end;
  4 /
begin
*
ERROR at line 1:
ORA-29532: Java call terminated by uncaught Java exception: java.lang.SecurityException
ORA-06512: at "SYSTEM.ER", line 0
ORA-06512: at line 2
--------------------------------------------
1. I've check the UTL_FILE_DIR parameter
2. If I comment out I/O-related codes, it gives no error. 3. If I use package UTL_FILE, it also works

PROCEDURE sp_er_buildfile
( i_file_name IN varchar2 )
AS
--DECLARE
  fileHandler UTL_FILE.FILE_TYPE;
BEGIN
  fileHandler := UTL_FILE.FOPEN('/usr2/oradata/esdcnt/udump', i_file_name, 'w');
  UTL_FILE.PUTF(fileHandler, 'Look ma, I''m writing to a file!!!\n');   UTL_FILE.FCLOSE(fileHandler);
EXCEPTION
  WHEN utl_file.invalid_path THEN

     raise_application_error(-20000, 'ERROR: Invalid path for file or path not in INIT.ORA.');
END sp_er_buildfile;


Thanks a lot.

Andy Kam
In article <38FF7D81.6C4EF57E_at_att.com>,   Raj <rajarulmani_at_att.com> wrote:
> Tom,
> External procedure fn getting executed correctly but the action
 is not being
> done . i,e creating a file / deleting a file / executing a file .
 Could you
> please let me know what i'm missing in my process.

>

> Here is the fn:
>

> int call_system ( char *progname , int a )
> {
>

> FILE *fp;
>

> fp = fopen ("test.txt","w");
>
> fprintf( fp , " First line is ! ");
>

> fclose( fp );
>

> }
>

> This code doesn't create the file "test.txt" .
>

> Tom Zamani wrote:
>

> > You need to provide us what version of database you are using.
> > If 7 then I have no Idea I am not sure if you can do that.
> > if 8.X you need to use external procedures in oracle
> > if 8.1.6 there is a package in oracle which could help you with
 this (I
> > don't know the name of the package).
> > I have used external procedures to do ftp ,cp, mv send email etc,
 and it is
> > very fast.
> >
> > Tom
> >
> > Raj <rajarulmani_at_att.com> wrote in message
 news:38FDF480.9D00B0B1_at_att.com...
> > > Hi,
> > > can any one tell me how to call a shell script from PL/SQL ?.
> > >
> > > Thanks,
> > > Raj
> > >
> > >

>
>

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Thu May 11 2000 - 00:00:00 CEST

Original text of this message