473,399 Members | 3,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

watching a file

Hey everyone,

Is there a way to "watch" a file for changes? I know I could poll the
file every few seconds and check to see if the buffer has changed but
is there a cleaner way?

thanks!

Ben
Nov 14 '05 #1
5 1604
"Benjamin D. LeMasurier" <ui*****@uidzer0.org> wrote in message
news:9c**************************@posting.google.c om...
Hey everyone,

Is there a way to "watch" a file for changes?
I assume you mean changes made by some other process.
Otherwise your program already 'knows' when it changes
things.
I know I could poll the
file every few seconds and check to see if the buffer has changed but
is there a cleaner way?


Depending upon your operating system, probably yes. But
standard C doesn't recognize the notion of multiple processes,
shared files, etc. Those issues are the domain of the operating
system. Ask in a forum which discuss your host platform.

-Mike
Nov 14 '05 #2

"Benjamin D. LeMasurier" <ui*****@uidzer0.org> wrote in message
news:9c**************************@posting.google.c om...
Hey everyone,

Is there a way to "watch" a file for changes? I know I could poll the
file every few seconds and check to see if the buffer has changed but
is there a cleaner way?
Depends on your OS. AFAIK, there is no standard 'C' way to do it. On a POSIX
system, stat() and check atime.
thanks!

Ben

Nov 14 '05 #3
"dandelion" <so*******@meadown.net> writes:
"Benjamin D. LeMasurier" <ui*****@uidzer0.org> wrote in message
news:9c**************************@posting.google.c om...
Hey everyone,

Is there a way to "watch" a file for changes? I know I could poll the
file every few seconds and check to see if the buffer has changed but
is there a cleaner way?


Depends on your OS. AFAIK, there is no standard 'C' way to do it. On a POSIX
system, stat() and check atime.


<OT>
mtime, not atime. For details, consult the documentation or an
appropriate newsgroup.
</OT>

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #4
"dandelion" <so*******@meadown.net> wrote in message news:<415d286d$0$147
Depends on your OS. AFAIK, there is no standard 'C' way to do it. On a POSIX
system, stat() and check atime.

I am in a linux/unix environment. I will give stat() a try

thanks!

Ben
Nov 14 '05 #5

"Keith Thompson" <ks***@mib.org> wrote in message
news:ln************@nuthaus.mib.org...
"dandelion" <so*******@meadown.net> writes:
"Benjamin D. LeMasurier" <ui*****@uidzer0.org> wrote in message
news:9c**************************@posting.google.c om...
Hey everyone,

Is there a way to "watch" a file for changes? I know I could poll the
file every few seconds and check to see if the buffer has changed but
is there a cleaner way?


Depends on your OS. AFAIK, there is no standard 'C' way to do it. On a POSIX system, stat() and check atime.


<OT>
mtime, not atime. For details, consult the documentation or an
appropriate newsgroup.
</OT>


<ot>
Right of course. Errare humanum est.
</ot>
Nov 14 '05 #6

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

Similar topics

8
by: Christopher Harrison | last post by:
I would like to, cleanly, watch a flat file for changes (updates and the like). The file will be altered by another program... I found some example code (which actually didn't compile) on Google,...
6
by: Ajay Pal Singh | last post by:
Hi, I am creating a web service, which needs to take some actions based on the config file. I need a way to listen the changes as they occur in the config file so that the service can take...
7
by: Claire | last post by:
Im sat here watching task manager and the memory consumption of my application rising second by second. What tools are there out there for me to use to find where it's all going please? (I wish...
0
by: aure_bobo | last post by:
Hi all, I'm currently developing an ASP.NET 1.1 C# Webapp. I have some objects which contains the differents parameters of my web app. These objects are instanciated in my code, in a static...
2
by: Stu | last post by:
Hi, I have been asked to interface with an AIX system running a COBOL application. Not having done this before we settled on text files written to a drive to communicate between the two systems....
8
by: Gordon Airporte | last post by:
I'm trying to find a way to take a file that another program has opened and writes to periodically, open it simultaneously in Python, and automatically update some of my objects in Python when the...
11
by: jcor | last post by:
Can anyone give me some help, plz I want to create a perl script to be watching a folder. Everytime a new file gets there it triggers some code; How can I do this? TIA, Joćo Correia
14
by: Zed A. Shaw | last post by:
Hi Everyone, Just putting out an announcement that I've released a new version of Vellum numbered 0.16. This version should be ready for people to use as not much of the internal structure has...
5
by: Andrew Cooper | last post by:
I've got an application that I'm modifying and the client needs it to watch a particular file and then do some stuff when that file gets modified. For example, let's say the file is C:\Test.dat...
3
by: canabatz | last post by:
Hi all i got a page that is refreshing data in a grid every 4 seconds and displaying results from the database and check if something as changed! my question is if there is 100 users that is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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,...

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.