473,507 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

flock and file(myfile.txt)

If I want to use file(myfile.txt) and myfile.txt gets written to (flocked)
frequently, what is the best approach?

Should I try to get a lock on myfile.txt before using file(myfile.txt)?

What I'm thinking is something like this:

try a few times to pull the file into an array

if you can, then do this

if not, die

Other ideas?

Thanks in advance.

Sep 7 '06 #1
1 1575
If I want to use file(myfile.txt) and myfile.txt gets written to (flocked)
frequently, what is the best approach?

Should I try to get a lock on myfile.txt before using file(myfile.txt)?

What I'm thinking is something like this:

try a few times to pull the file into an array

if you can, then do this

if not, die

Other ideas?

Thanks in advance.
How about this:

$myfile = "/path/to/myfile.txt";
$timeout = 0;
while ($timeout < 10)
{
if ($myarray = file($myfile))
{
break;
}
else
{
usleep(100000);
}
$timeout++;
}

Is this the right way to test file(myfile) ??

Sep 7 '06 #2

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

Similar topics

3
2982
by: comp.lang.php | last post by:
Using Linux/PHP 4.3.2 CLI: $fileID = fopen('myfile.txt', 'r'); // WORKS JUST FINE Using Linux/PHP 4.3.8 CLI: $fileID = fopen('myfile.txt'); // THROWS WARNING 'no such file or directory...
1
3817
by: Ashutosh | last post by:
How can i convert Word file to txt file in ASP.NET using CSharp?
4
9153
by: MLH | last post by:
Is it good programming practice to delete existing file before running Open "c:\MyFile.txt" For Output As #1 ??? IE, I already have a file c:\MyFile.txt on disk and I launch Open "c:\MyFile.txt"...
0
1078
by: tnt84 | last post by:
I wrote a C++ source code as "phone.txt" that is below and now I want a program that reads the input from this file "phone.txt" and writes the input to "output.txt" #include <iostream> ...
3
2474
by: Learning.Net | last post by:
How to read a Unicode data saved as ASCII in notepad file as txt ? I tried using streamReader but it is not showing Unicode data. eg. using (StreamReader sr = new StreamReader(test.txt) {...
1
2973
by: sara ajay | last post by:
i want to convert .doc file to .txt file using C#, plzz can any one help me to come over this problem.
1
1245
by: Raymond Pittman | last post by:
Hi I need to know how to save my name in a data file named myfile.txt any help for a beginner.
22
11725
by: xiao | last post by:
Can I fullfill this task? Using fred and fwrite?
2
1684
by: ishakarthika | last post by:
i have a .txt file which contains line of string like the below format |111|34 sdddd| ppppp| A/C| 32| sadfd| |4324|23 mmm| yyyyy| A/C|32| fdfffdfd| the sixth column is the no...
0
7110
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7314
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7372
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
7482
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5623
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,...
0
4702
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...
0
1540
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 ...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.