To read Unix log file

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
wassam
Participant
Posts: 5
Joined: Mon Mar 03, 2008 11:32 am

To read Unix log file

Post by wassam »

hi

i want to read a file in unix server in monthly basis
the file name will be datard1.log,once the file is processed next file the data will be written
then in next month i want to read datard2.log file
datard1.log file will be in the same server

we have only read access to the server
based upon the modified date i have to read the file

file name will be same like datard....

but the number will be changing like
datard1.log
datard2.log
" .
" .
datard9.log

can this be done in datastage or in unix

if it can only done by unix can you give the script

thanks in advance
belaruska
Premium Member
Premium Member
Posts: 12
Joined: Wed Feb 28, 2007 5:00 pm

Re: To read Unix log file

Post by belaruska »

you will need to create a counter to keep track of the files alredy processed. you can create one in a table or in a file.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Checkout using ssh to run a directory listing on the unix server, then take the name of the desired file and pass it to an scp command to copy the file to your local DataStage server.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
wahi80
Participant
Posts: 214
Joined: Thu Feb 07, 2008 4:37 pm

Re: To read Unix log file

Post by wahi80 »

Hi,
Try this script it should work
ls -t|tail -1 > newfile

Working
ls -t lists file by creation date, just check the order of listing
tail -1 will pick the last line, which I think will be the latest file, this is written into newfile.
Let me know if it worked
Post Reply