Page 1 of 1

How to read the file from the end

Posted: Mon Oct 08, 2007 10:03 am
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

Posted: Mon Oct 08, 2007 10:46 am
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.

Posted: Mon Oct 08, 2007 2:55 pm
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.