Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to verify a file is closed in NT

Status
Not open for further replies.

rickgerdes

IS-IT--Management
Feb 11, 2003
44
US
Here's the deal-

I need to have a program (PERL) know when a file is closed. Specifically what I am trying to do is wait for a process that may or may not be running to complete. If it's running, it is writing a log file, if it's done, the last log in the directory should be closed.

I can find the file just fine, but I cannot figure out how to either read it (correctly) for checking for the reference to it's being complete, or checking some unary to see if it's open. I'm going nuts here.

The logs are in xml and trying to read them give me inconsistent data. Most parse to flat text, but a few parse to spaces between characters. So reading for completetionStatus sometimes needs to be c o m p l e t i o n S t a t u s, but that pattern doesn't match correcly. I'd rather not read the file at all.

Simplest process- look in a given directory for the last file with .xml extension. Is it being written to? If yes, wait five minutes and check again, if not, continue on.

Any help out there? Thanks folks!
 
Look up flock, and if you can't get a lock on the file the other process hasn't completed

I think flock has been implemented on NT based OS's though I haven't personally tested it

HTH
Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
rickgerdes,

You might want to look at the Job module which was recently introduced for Windows 2000. It is included in ActivePerl 5.6 and can be found in the documentation. I haven't used it myself, but came acrossed it last evening after reading your request. After a brief inspection, the Job module sounds like something you would be interested in.

Any other suggestions guys?

peege
 
While not exactly what I need, I think I might be able to cobble something together from the joblist. Thanks for the pointer!
 
PaulTEG- I've tried working with flock under NT in the past. I do believe that's where its going to stay. The implementation is horrible and not at all useful as far as my limited understanding goes. Until I convince TPTB to migrate to Linux boxes (which will be right after porcine bodies levitate out a posterior orifice) I'll be stuck trying other procedures. Thanks though!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top