Here is a adoption for running the ls command ... be very careful with suspriv 
command, it is very powerful privilege. One could replace ls with rm and then you are 
doomed if oracle is running as root.

grant javasyspriv to system
/
create or replace type fileList as table of varchar2(255)
/

create or replace and compile java source named "DirList"
as
import java.io.*;
import java.sql.*;
import oracle.sql.*;
import oracle.jdbc.driver.*;
public class DirList
{
public static ARRAY getList(String directory)
                             throws SQLException
{
    File path = new File( directory );
    Connection conn =
          new OracleDriver().defaultConnection();
    ArrayDescriptor descriptor =
      ArrayDescriptor.createDescriptor( "FILELIST", conn );
    return new ARRAY( descriptor, conn, path.list() );
}
}
/
create or replace function get_dir_list( p_directory in varchar2 )
  return fileList
as language java
name 'DirList.getList( java.lang.String )
      return oracle.sql.ARRAY.ARRAY';
/
set serveroutput on
declare
    l_files  fileList;
begin
    dbms_output.enable(1000000);
    l_files := get_dir_list( '/home/oraclei/code' );

    for i in 1 .. l_files.count
    loop
        dbms_output.put_line( l_files(i) );
    end loop;
end;
/

Raj
--------------------------------------------------------------------------------
Rajendra dot Jamadagni at nospamespn dot com
All Views expressed in this email are strictly personal.
QOTD: Any clod can have facts, having an opinion is an art !


-----Original Message-----
Sent: Thursday, December 04, 2003 12:00 PM
To: Multiple recipients of list ORACLE-L


yeah, I'm trying to get away from C external procedures ...but java is
beginning to look just as much a hassle.

Why is running a OS command such hassle?



**************************************************************************************
This e-mail message is confidential, intended only for the named recipient(s) above 
and may contain information that is privileged, attorney work product or exempt from 
disclosure under applicable law. If you have received this message in error, or are 
not the named recipient(s), please immediately notify corporate MIS at (860) 766-2000 
and delete this e-mail message from your computer, Thank you.
**************************************************************************************5
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Jamadagni, Rajendra
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to