How to read the file from the end

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
sprasad55
Participant
Posts: 11
Joined: Thu Dec 28, 2006 4:16 pm

How to read the file from the end

Post by sprasad55 »

I am writing FTP log to a file every day(same file), I need to read this file every day and send an e-mail when there are error message.

I am planning to read from the end-of file until the begining of that day's log so that I will be reading only that day's log, planning to send an e-mail when I encounter any error message.

If possible Can any one suggest me how to get the file pointer so that I can read from the end of file? OR how to do SEEK -1.

Thanks
nick.bond
Charter Member
Charter Member
Posts: 230
Joined: Thu Jan 15, 2004 12:00 pm
Location: London

Post by nick.bond »

On Unix i would probably use the tail command in the filter options of the sequential file stage to take a chunk of the end of the file and work with that. I haven't used them but i am pretty sure you can download tail for windows from the web, probably even from MS now.
Regards,

Nick.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

In DataStage BASIC SEEK filevariable,offset,location postitions the file pointer offset characters away from location, and offset can be negative or positive. For location 0 means current location, 1 means beginning of file and 2 means end of file.

If the file is not too big to read as a single dynamic array, you might be able to leverage the REVREMOVE statement. Use SETREM to position the remove pointer to end of file (Len(string)+1) first.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply