Detecting open files and forcing closure

Rhodri James rhodri at wildebst.demon.co.uk
Fri Jan 9 23:38:18 EST 2009


On Sat, 10 Jan 2009 03:06:03 -0000, Andrew Robert <arobert at townisp.com>  
wrote:

> The usual scenario is that a user will leave a PDF open and then go home  
> for the evening. They are simply viewing and not modifying the file.  
> When the XCOPY executes, it signals a failure and subsequent scheduler  
> job abend.
>
> What I need to do is detect if files are open for viewing and force a  
> close before the copy operation is attempted.
>
> Sleeping and retrying the copy is not an option because the user will  
> likely leave it open all night.
>
> Is there a way to detect the open files and close them out?

I can't think of one off the top of my head, but this approach will cause
more anguish than you would believe possible in any case.  Imagine if the
file was open for write; you've either just corrupted it or lost the most
recent work if you force it closed.

It sounds like you're trying to implement a backup strategy.  If you are,
I'd suggest your problem is XCOPY -- you really need something more
combat capable instead.

-- 
Rhodri James *-* Wildebeeste Herder to the Masses



More information about the Python-list mailing list