A simpler alternative might be to have a cron job construct a file list every so often, and define an external table to read that. The script called from cron would be something like:
#!/bin/ksh
find . -type f -newer files_xt.dat >/dev/null && \
for f in test*.dat
do
ls -l $f | read privs nodes owner group size month day time filename
print ${filename},${owner},${group},${size},${privs},\"$(date +%Y)-${month}-${day} ${time}\"
done > files_xt.dat
which would produce a file like this
test20050101.dat,williamr,staff,2,-rw-r--r--,"2005-Jun-11 17:51"
test20050102.dat,williamr,staff,2,-rw-r--r--,"2005-Jun-11 17:50"
test20050103.dat,williamr,staff,2,-rw-r--r--,"2005-Jun-12 09:41"
test20050104.dat,williamr,staff,2,-rw-r--r--,"2005-Jun-13 10:21"
test20050105.dat,williamr,staff,2,-rw-r--r--,"2005-Jun-14 14:33"
and the external table could be defined something like:
CREATE TABLE files_xt
( filename VARCHAR2(50)
, permissions VARCHAR2(10)
, owner VARCHAR2(10)
, owner_group VARCHAR2(7)
, file_date DATE )
ORGANIZATION EXTERNAL
( TYPE oracle_loader
DEFAULT DIRECTORY william_test
ACCESS PARAMETERS
( RECORDS DELIMITED BY newline
LOAD WHEN (1:1) != "#"
BADFILE 'files_xt.bad'
DISCARDFILE 'files_xt.dis'
LOGFILE 'files_xt.log'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
( filename
, owner
, owner_group
, nodes
, permissions
, file_date DATE "YYYY-Mon-DD HH24:MI" )
)
LOCATION ('files_xt.dat')
)
REJECT LIMIT UNLIMITED;
and it would look this this in the database:
SQL> desc files_xt
Name Null? Type
----------------------------- -------- --------------------
FILENAME VARCHAR2(50)
PERMISSIONS VARCHAR2(10)
OWNER VARCHAR2(10)
OWNER_GROUP VARCHAR2(7)
FILE_DATE DATE
SQL> col filename format a20
SQL> SELECT * FROM files_xt;
FILENAME PERMISSION OWNER OWNER_G FILE_DATE
-------------------- ---------- ---------- ------- -----------
test20050101.dat -rw-r--r-- williamr staff 11-JUN-2005
test20050102.dat -rw-r--r-- williamr staff 11-JUN-2005
test20050103.dat -rw-r--r-- williamr staff 12-JUN-2005
test20050104.dat -rw-r--r-- williamr staff 13-JUN-2005
test20050105.dat -rw-r--r-- williamr staff 14-JUN-2005
5 rows selected.
[Updated on: Sat, 18 June 2005 08:17]
Report message to a moderator