perl_runner wrote: > Hello, > Anyone know how to read a file but not interfere with the file’s owner > (process) from re-naming the file?
Switch to UNIX. :) > I have an app that periodically (every few seconds) reads a log file > generated by a server, then mangles data and finally reports what it finds > from the log file’s contents. > > The server periodically stops writing to the current file and start writing > to a new file… when it closes the old file, it renames it (or tries too!). > > Rarely (but problematically) the server is unable to rename the log file it > just finished because my perl app has opened it for reading (its open for a > very brief time using a standard open <below>). > > open (CURREVNT, "$current_event_log”) || warn "-332 Open Current Logfile > Failed (ERR: $! )\n"; > > Is there any way for me too read the contents of the log files without > preventing the server from re-naming it (on the odd occurrence when the two > collide)? You could try do a shared read using Win32::API and CreateFile lib routine with FILE_SHARE_READ ShareMode and OPEN_EXISTING CreationDistribution. Not 100% sure that will solve it, but worth a try. If Windoze programmers would get their sh*t together, they would find a way to emulate some of the good UNIX features - like using a use count on files so you could delete a file in use and have it disappear after the use count goes to 0. > Extra stuff: > a. Platform->Windows NT 4 Svc Pack 6 [Without Perl (app compiled using > Perlapp and running on NT 4)] > b. Perl Program running as administrator (same as server process owner) > c. 1 GB Physical Mem > d. System Nominally operates at about 60% of its processing capacity _______________________________________________ Perl-Win32-Users mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
