473,586 Members | 2,817 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Open file handles?

This may be more of a Linux question, but I'm doing this from Python. .....

How can I know if anything (I don't care who or what!) is in the middle of
using a particular file?

This comes in context of needing to copy a file BUT only if I can verify
that something else doesn't have an open write handle to that file. IOW - I
need to decline the operation if something else hasn't finished writing to
the file.

How can I know?
Thomas Bartkus
Aug 8 '06 #1
3 3964
Jon
Perhaps using os you could work with lsof
[http://www.linuxcommand.org/man_pages/lsof8.html]

Jon

Thomas Bartkus wrote:
This may be more of a Linux question, but I'm doing this from Python. .....

How can I know if anything (I don't care who or what!) is in the middle of
using a particular file?

This comes in context of needing to copy a file BUT only if I can verify
that something else doesn't have an open write handle to that file. IOW - I
need to decline the operation if something else hasn't finished writing to
the file.

How can I know?
Thomas Bartkus
Aug 8 '06 #2

"Jon" <js****@gmail.c omwrote in message
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
Perhaps using os you could work with lsof
[http://www.linuxcommand.org/man_pages/lsof8.html]

Jon
Of course! That's perfect.
Thank you!

How silly of me not to have noticed that "lsof" means "ListOpenFi les" ;-)
Thomas Bartkus

Aug 9 '06 #3
Is there an equivalent in windows?

Jon wrote:
Perhaps using os you could work with lsof
[http://www.linuxcommand.org/man_pages/lsof8.html]

Jon

Thomas Bartkus wrote:
This may be more of a Linux question, but I'm doing this from Python. .....

How can I know if anything (I don't care who or what!) is in the middle of
using a particular file?

This comes in context of needing to copy a file BUT only if I can verify
that something else doesn't have an open write handle to that file. IOW - I
need to decline the operation if something else hasn't finished writing to
the file.

How can I know?
Thomas Bartkus
Aug 10 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1807
by: jnc | last post by:
I have quite a weird problem whereby I need to obtain the username of the person who has a file open and it need to work over the nework. To explain a bit more.....I have a file system watcher which is watching a file over the network. The file can be opened by multiple users from mutiple computers within the same domain. Currently the...
2
1529
by: Benjamin Rutt | last post by:
If I did the following in an infinite loop, would the host system/user account soon run out of file descriptors? (I'm thinking no, since I'd imagine that a file object has a __del__-like method that will call close() automatically since it goes out of scope): open('/home/rutt/.bashrc,'r').read() Can anyone confirm that I'm right in...
46
5967
by: Steve | last post by:
Access97 Database The database is split into a frontend and backend and not connected to any other database. The database has an unbound report with 15 subreports. Some of the subreports include Excel charts in unbound object frames. When I add 3 additional subreports, I get the error message that Access can't open any more databases. Can...
15
2445
by: Dave | last post by:
Has anyone encountered the error message "Can not open any more databases" and what did you do to solve it? Thanks, Dave
6
1376
by: Mark Broadbent | last post by:
Everything I have read suggests that if I open files or database connections or the like, that I should explicitly close those said resources before making the object subject to GC. This is obviously good programming technique. However what happens if this practice is not followed. e.g. that I have a base object that creates an instance of...
13
39864
by: Chris Johnson | last post by:
I have what seems to be such a simple thing yet I cannot figure out how to do it. I am using a streamwriter to build a text file. At the end of the process I want to open that same text file in notepad so the user can see what was built. I cannot for the life of me figure out how to get the text file to open up in notepad on the screen....
1
1743
by: dwainew | last post by:
Problem: I'd like to archive off the contents of a text file. However, other processes may have the file open, so MoveTo(newfilepath) can't be done, as far as I've found. Start with a 5 MB MyLog.txt file that may be opened (reading and/or writing) by several handles. The Final state I'm looking for is an archive file...
5
11192
by: Ryan Liu | last post by:
Hi, Both way works, I'd just ask some experts which way is better? My application creates a log file daily. Now each time when I write a log, I will open the file and append to the end. Ocz, if the file is not exist(e.g. another day), it will creates the file first.
0
1836
by: Fendi Baba | last post by:
I created an ASP.net page which opens excel. This works fine in Office 2007. However, Excel 2003 runs in an error which states "cannot read output file". Hee is the VB code and below is the ASPX code. Imports System.Data.SqlClient Imports System.Web.Configuration Imports System.Web.UI
2
2441
by: TG | last post by:
Hi! Once again I have hit a brick wall here. I have a combobox in which the user types the server name and then clicks on button 'CONNECT' to populate the next combobox which contains all the databases in that server. Then after the user selects a database, I have another button that he/she click and I want to retrieve file groups from a...
0
7911
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7954
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1448
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.