?
Solved

Read the file ...before actual write ??..or the last written data

Posted on 2007-08-01
5
Medium Priority
?
143 Views
Last Modified: 2011-09-20
what i want to build is a log file monitor...or rather a virtual logfile monitor.

My problem is as follows.
I have an server and clients spread all over the network. I do not want to use winsock due to certain restrictions.
All the clients have write acess to a certain directory on the net work.

what i want to do is some thing like this.
when the server wants to a send a command to a specific client it will write into the \command\<MAchineName> file
the client need to detect this change and get what is what was written and take actions..
and report in
\response\<MachineName>

now  I have looked into these solutions
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_21542107.html
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_21890897.html

what i want to know is ...is it possible to read what is beind written ..before it is acctually wriiten on the disk...either on the local or remote machine.
I know i can detect a file modify. but is it possible to detect what was being written so that instead of parsing the entire file...which may become very very big since it is a 24/7 application ...i only get what was the last written thing???



0
Comment
Question by:mandelia
  • 3
  • 2
5 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 19607165
if you really want to make the process safe using files, you need 2 files each time:

1 file containing the command
1 file containing the acknowledge that the command file is complete.

like:
command.<machine>.20070801.110302.txt
command.<machine>.20070801.110302.ack

so the server has to write the .txt file first, and then only the .ack file.

the client has then to check only if there are .ack files, and for each .ack file, get and process the corresponding .txt file.
and once it has processed the file, delete both the .ack and the .txt files.

so, do NOT create 1 file per client, but 1 file per "command".
0
 
LVL 5

Author Comment

by:mandelia
ID: 19607369
Actually that is exactly what i want to avoid...
Please check the solution which i have attached ..
what i want to do is to "intercept the write" if it is possible....
meaning when the file is being written on the disk the data which is written come .i am able to peek into it..

if this is not clear let me try to explain it with an example.
Consider a client ABC , and DEF using the directory \logs
when the serven wants to send a command to the ABC ..
it appends the COMMAND to the end of COMMAND.ABC.log

if it wants to send the command to DEF then
the server then it append the command to the end of COMMAND.DEF.log

consider the example in the links given above ..i can easily detect whan a change has occured in a given file...i.e some thing has written into it...

in a normal way ..yes i would chek the ack file if it exists and tht menas the server has finished writing
and  then i can read to the end of the file to process the command....

two resoan why i do not want to do this
1) There may be multiple commands .one after the other
..therefore..there is a chace of a clash




0
 
LVL 5

Author Comment

by:mandelia
ID: 19607386
continued....
2) i do not want the client to delete the files...since i want the server to have them open though out the session

what i am trying to do is to basically be able to peek into what the server is writing ...while it is writing or just after it is finished.

Is this possible...or do i have to read to the end of the file everytime...
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1500 total points
ID: 19607404
then, you will need to use some pipe/queing mechanism (like MSMQ or the like).
you cannot intercept a file write, although you can detect that a change happens.
0
 
LVL 5

Author Comment

by:mandelia
ID: 19607489
hmmm.....thank you for that answer....

I have already tried winsock..and failed due to too many no of clients... and other issues ..

is there a better messaging method....(MSMQ not supported) that u can think of?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question