|
-
I got this from asktom.com and I have explained below how to use this daemon in your pl/sql to get the file names.
I have tried it and it works like a charm !!!
hope this helps
-----------------------------
This is a quick and dirty daemon -- written in csh (the cool shell)..
Here is a PL/SQL subroutine you can install in your schema:
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;
/
Here is a C-Shell script you can run in the background (use this shell script
make sure it is named host.csh)
-------------------- bof ----------------------------
#!/bin/csh -f
sqlplus user/password <<"EOF" | grep '^#' | sed 's/^.//' > tmp.csh
set serveroutput on
declare
status number;
command varchar2(255);
begin
status := dbms_pipe.receive_message( 'HOST_PIPE' );
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 host.csh' );
end if;
end;
/
spool off
"EOF"
chmod +x tmp.csh
exec tmp.csh
----------------------- EOF ---------------------------------
SQL> exec host( 'ls -l' );
SQL> exec host( 'echo Hello World' );
Your can then do some thing like ...
Begin
host('ls > file_list');
read file names from file_list using UTL_FILE
...
...
end ;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|