On Fri, Nov 28, 2008 at 00:09, Anirban Adhikary
<[EMAIL PROTECTED]> wrote:
snip
> my $lock_file="/home/bighosh/OraOneLoader_3.0.2/Source/flocktest.txt";
> open LOCKFILE, ">>$lock_file" or die "Cannot open $lock_file $!";
>
> while( )
> {
file has been
locked it will wait until the lock has been released , then again it will
open the file lock it and write data. Both the programs will running in
while( ) loop.
my code is as follows
*prog1.
*use strict;
use warnings;
use Fcntl qw(:flock);
my $lock_file="/home/bi
On Mon, Mar 17, 2008 at 4:47 PM, Dermot <[EMAIL PROTECTED]> wrote:
snip
> print $fh $status."\n";
> print STDERR "$0: $! $?\n";
snip
$? holds the status returned by the last external call (call to
system() function, pipes, qx// operator, call to wait() or waitpid(),
u should probably also include
O_APPEND with the third argument.
You want to either use parentheses:
sysopen( my $fh, $file_path, O_WRONLY | O_APPEND ) || die "can't open
$file_path: $!\n";
Or use the low precedence 'or' operator:
sysopen my $fh, $file_path, O_WRONLY | O_APPE
can't open
$file_path: $!\n";
flock($fh,LOCK_EX) or die "can't lock $file_path: $!\n";
seek($fh, 0, 2); # Append to file
print $fh $status."\n";
print STDERR "$0: $! $?\n";
c
Dermot schreef:
>sysopen my $fh, $file_path, O_WRONLY
>|| die "can't open $file_path: $!\n";
Change or-operator (or use parenthesis).
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL
open
$file_path: $!\n";
flock($fh,LOCK_EX) or die "can't lock $file_path: $!\n";
seek($fh, 0, 2); # Append to file
print $fh $status."\n";
print STDERR "$0: $! $?\n";
close($fh);
file.
snip
I am not sure what you are asking, but I assume you don't understand
what the flock flags are for. The flock function normally waits until
a lock can be achieved. This could be forever (especially in the case
of a deadlock*), so it provides a flag LOCK_NB that lets you tell
In this code:
BEGIN {
use Fcntl ':flock';
open( DATA, qq(C\:\\temp\\file.txt) )
or die "file handle was not opened: $!";
for my $foo () {
print $foo;
}
flock DATA, LOCK_EX | LOCK_NB or exit 0;
}
Is there anything more one could add to thi
On Wed, 12 Oct 2005 09:55:12 -0400, Tom Allison wrote:
> How do I test for NFS mounting so I can flag it as a problem in my code?
The device number may be negative; try it and see. perldoc -f stat.
--
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/
--
To unsubscribe, e-mai
On Oct 13, 2005, at 12:13, Tom Allison wrote:
John Doe wrote:
Tom Allison am Mittwoch, 12. Oktober 2005 15.55:
[...]
Since you got no answer yet from somebody knowing better:
thanks, I'll look into it. I'm at a disadvantage since it is
difficult to install something on this machine. I'm
John Doe wrote:
Tom Allison am Mittwoch, 12. Oktober 2005 15.55:
[...]
Since you got no answer yet from somebody knowing better:
thanks, I'll look into it. I'm at a disadvantage since it is difficult
to install something on this machine. I'm not root.
--
To unsubscribe, e-mail: [EMAIL PRO
Tom Allison am Mittwoch, 12. Oktober 2005 15.55:
[...]
Since you got no answer yet from somebody knowing better:
> How do I test for NFS mounting so I can flag it as a problem in my code?
hand made: examine /proc/mounts ...
But I'm shure there are much better ways.
> What options are there for
perldoc says I can't do flock over a network.
I assume this is NFS mounted files.
Two questions:
How do I test for NFS mounting so I can flag it as a problem in my code?
What options are there for locking over NFS besides using foo.lock files
all over the place?
--
To unsubscribe, e
- Original Message -
From: bclark1 <[EMAIL PROTECTED]>
Date: Thursday, July 14, 2005 6:48 am
Subject: flock and open files
> Hi list
Hello,
>
> My colleaque and I have just had a small disagreement with each
> other
> about file locking and reading / ammending a
says the flocking does not
work on Linux, where as I say the flock works for both Linux as well as
win32. I read the perldocs and I have not seen anything proving him
right, but as the same time I have not seen anything that proves him wrong.
So if anyone share their experiences or tips is would
On Tue, 14 Dec 2004 17:21:04 +0200, Octavian Rasnita <[EMAIL PROTECTED]> wrote:
> Thanks but I don't have access to MySQL nor to the client that makes the
> update. I don't even know if it locks the tables or not.
>
> I would like to just copy some files in order to create a backup but I don't
> w
> -Original Message-
> From: Octavian Rasnita [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, December 14, 2004 9:21 AM
> To: Ron Goral; [EMAIL PROTECTED]
> Subject: Re: MySQL and flock
>
>
> Thanks but I don't have access to MySQL nor to the client that makes the
&
IL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, December 14, 2004 4:32 PM
Subject: RE: MySQL and flock
> -Original Message-
> From: Octavian Rasnita [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, December 14, 2004 6:57 AM
> To: [EMAIL PROTECTED]
> Subject: MySQL an
> -Original Message-
> From: Octavian Rasnita [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, December 14, 2004 6:57 AM
> To: [EMAIL PROTECTED]
> Subject: MySQL and flock
>
>
> Hi all,
>
> Does anyone know if MySQL uses flock when it modifies the data from a
Hello,
I wrote a script which involved writing a file, which may als be writing
by another script. To prevent crashes, I want to used the flock() function.
my question is:
How do I check if a file is locked by other script or I simply can't read?
Koala
--
To unsubscribe, e-mail: [EMAIL PROT
Hi all,
Does anyone know if MySQL uses flock when it modifies the data from a
database for locking the files in which are kept the modified tables?
I want to make a perl program which gets the file and store a back-up but I
don't want to get the files while they are modified.
Than
On Tue, 14 Dec 2004 11:03:56 +0800, Shu Hung (Koala) <[EMAIL PROTECTED]> wrote:
> Hello,
> I wrote a script which involved writing a file, which may als be writing
> by another script. To prevent crashes, I want to used the flock() function.
>
> my question is:
> How
Smoot Carl-Mitchell wrote:
On Wed, 07 Apr 2004 14:50:54 -0500
"JupiterHost.Net" <[EMAIL PROTECTED]> wrote:
So flock(FH, LOCK_EX | LOCK_NB) then?
Yes.
So:
my $rc = flock(FH, LOCK_EX | LOCK_NB);
if($rc == 0) { warn "rats! Exclusive lock not granted, oh well...";
On Wed, 07 Apr 2004 14:50:54 -0500
"JupiterHost.Net" <[EMAIL PROTECTED]> wrote:
> So flock(FH, LOCK_EX | LOCK_NB) then?
Yes.
> So:
> my $rc = flock(FH, LOCK_EX | LOCK_NB);
>
> if($rc == 0) { warn "rats! Exclusive lock not granted, oh well..."; }
>
Smoot Carl-Mitchell wrote:
On Wed, 07 Apr 2004 13:51:03 -0500
"JupiterHost.Net" <[EMAIL PROTECTED]> wrote:
perldoc -f flock says
"If LOCK_NB is bitwise-or'ed with LOCK_SH or LOCK_EX then "flock"
will return immediately rather than blocking waiting for t
On Wed, 07 Apr 2004 13:51:03 -0500
"JupiterHost.Net" <[EMAIL PROTECTED]> wrote:
> perldoc -f flock says
>
> "If LOCK_NB is bitwise-or'ed with LOCK_SH or LOCK_EX then "flock"
> will return immediately rather than blocking waiting for the lock
&
perldoc -f flock says
"If LOCK_NB is bitwise-or'ed with LOCK_SH or LOCK_EX then "flock" will
return immediately rather than blocking waiting for the lock (check the
return status to see if you got it)."
So that would mean:
use Fcntl ':flock';
flock(FH, LOCK
Shaun Fryer wrote:
>
> I'm writing an app which uses a flat file to store a
> *short* list of simple key/value pairs. However having
> read the flock() man page, I'm unsure about whether I
> need to seek() in cases where I'm not merely appending
> to the fil
Hi all,
I'm writing an app which uses a flat file to store a
*short* list of simple key/value pairs. However having
read the flock() man page, I'm unsure about whether I
need to seek() in cases where I'm not merely appending
to the file (such as when deleting a record).
su
Hi,
I'm trying to get flock to behave consistently between IRIX,Solaris
and Linux (2.4.x).
When I run the following Perl Program, IRIX and Solaris allows the Shared
lock (and doesn't execute the inside of the while loop)
Where as, Linux denies the Shared lock with "Resou
Hi,
I'm trying to get flock to behave consistently between IRIX,Solaris
and Linux (2.4.x).
When I run the following Perl Program, IRIX and Solaris allows the Shared
lock (and doesn't execute the inside of the while loop)
Where as, Linux denies the Shared lock with "Resou
[EMAIL PROTECTED] wrote:
I'm learning on a win98 machine and my webserver is a unix OS.
win98 doesn't support flock and of course unix does.
How can I code to test if the function is supported? I tried conditionals
but it still throws the error.
What conditionals did you try? S
I'm learning on a win98 machine and my webserver is a unix OS.
win98 doesn't support flock and of course unix does.
How can I code to test if the function is supported? I tried conditionals
but it still throws the error.
On Sun, Jun 01, 2003 at 09:35:56AM -0700 Bob's Demise wrote:
> I've written a Perl/CGI that allows a user to search
> for a string in a specified file. I've yet to make
> this little program widely available - and currently
> with one or two users - it's quite speedy. I
> anticipate no more than
Rob Dixon wrote:
> Bob'S Demise wrote:
> > Hello
> >
> > I've written a Perl/CGI that allows a user to search
> > for a string in a specified file. I've yet to make
> > this little program widely available - and currently
> > with one or two users - it's quite speedy. I
> > anticipate no more tha
Bob'S Demise wrote:
> Hello
>
> I've written a Perl/CGI that allows a user to search
> for a string in a specified file. I've yet to make
> this little program widely available - and currently
> with one or two users - it's quite speedy. I
> anticipate no more than 20 users attempting to access
>
Hello
I've written a Perl/CGI that allows a user to search
for a string in a specified file. I've yet to make
this little program widely available - and currently
with one or two users - it's quite speedy. I
anticipate no more than 20 users attempting to access
the same file at the same time -
Hello
I have an issue with Solaris 8 and flock. What I'm trying to do is copy files from an
ftp dropbox to another directory, but skip open files (files that are currently being
ftp'd into the dropbox). Seems that the line :
if ( ! (flock(LOCK, LOCK_EX | LOCK_NB))) {
On Mon, 11 Nov 2002, Nisim, Amit wrote:
> Hi All,
>
>
> flock doesn't work when I am running flock to file x from different machines.
>
> What I mean:
> I am running flock from machine XXX on file z
> If I try to write to file z from machine YYY I succeed.
>
Hi All,
flock doesn't work when I am running flock to file x from different machines.
What I mean:
I am running flock from machine XXX on file z
If I try to write to file z from machine YYY I succeed.
Do you know mechanism like flock that work on several machines ?
Amit
Why does exclusive flock give Bad file number (Solaris)?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
From: "Jay M" <[EMAIL PROTECTED]>
> I am attempting to modify a script that was coded back when perl 4.xx
> was the current version. This script accesses databases using DB_File
> and dbmopen(). After every dbmopen and dbmclose there is a flock().
> For example.
Hi,
I am attempting to modify a script that was coded back when perl 4.xx was
the current version. This script accesses databases using DB_File and
dbmopen(). After every dbmopen and dbmclose there is a flock(). For
example.
dbmopen(%DB, $filename, 0777) || die "Error: $!\n";
I thought that Solaris perl emulated flock() using fcntl(), but the
emulation appears not to work.
Do I need to define any special flags when I compile perl in order to get
the emulation?
Unfortunately I am not in a position to upgrade my gcc or my OS at the
present time.
Thanks,
Smiddy
P.S.
Hi,
I posted this message this morning.
Is there anybody who can help?
Thank you
On Wednesday 06 February 2002 10:33, Alain wrote:
> Hi,
>
> I need to use flock function with files on nfs partitions.
> I've read that flock only works with local files, and that perl needs to b
Hi,
I need to use flock function with files on nfs partitions.
I've read that flock only works with local files, and that perl needs to be
configured to use fcntl by default, instead of flock.
The only information I found is to use "-Ud_flock" with the Configure script.
Does
> -Original Message-
> From: Rich Fernandez [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, November 20, 2001 2:23 PM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: flock problem on AIX 4.3.3
>
>
> Hello,
>
> A colleague is experiencin
few entries. We are using flat files and not a
database.
We wrote to Lincoln and he provided us with a script which pointed us to a
problem with our
version of flock, so we rebuilt Perl with the -Ud_flock option to configure
which,
according to the doco, causes perl to not use flock and instead use
use Fcntl qw(:flock);
until(flock $fh, LOCK_EX|LOCK_NB)
{
$lockwait++;
if($lockwait == 10)
{
print STDERR "timed out waiting for lock\n";
exit 1;
}
sleep 1;
}
this will do a non-blocking attempt to get the lock,
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi,
>
> I'm trying to lock a file exclusively so that other process has no access
> to it
> I'm using:
>
> flock($fh,2);
>
> It does work, and in the second process I use the same procedure.
>
> Th
Hi,
I'm trying to lock a file exclusively so that other process has no access
to it
I'm using:
flock($fh,2);
It does work, and in the second process I use the same procedure.
The problem is that I can't set a time limit for the lock.
I want to try to capture the lock, and if un
>
> open(FILE,">$datafile");
> flock(FILE, LOCK_EX);
> print FILE "$input\n";
> close(FILE);
>
> Notice that I do not use flock(FILE, LOCK_UN); before I close
> the file. I
> don't use it because I was told not to by the server administrat
I'm switching from a Linux server to a Windows 2000 server, which I've
previously mentioned on this list. I've also asked about flock before, but I
have another question.
Currently on the Linux box, I have flock setup like this.
at the top of the script
use Fcntl qw(:flock
;re done.
If you have admin privs on the system in question, check out the
File::Flock module, which should handle logfile stuff for you
automatically.
# perl -MCPAN -e shell
cpan> install File::Flock
# perldoc File::Flock
flock() is also somewhat system-dep
back.
(Quoted below for those who want to read the backthread, but I added
nothing below here.)
--- Peter Cornelius <[EMAIL PROTECTED]> wrote:
> I was a little confused because you are talking about users in your
> original post. If you flock a file and a user can still view it,
>
Nichole Bialczyk wrote:
> i'm curious as to how secure flock is. if the file is locked and another
> user tries to access it, does it wait or does it kick them off?
It depends. The main thing to consider is that in general file
locking is a voluntary sort of arrangement. When you
I was a little confused because you are talking about users in your original
post. If you flock a file and a user can still view it, probably edit it. If
only your scripts are accessing the file then you are pretty safe. At least
that's my understanding.
Peter C.
> i'm trying
i'm trying to lock a log file wheneber a new visitor enters the page and
also when we run scripts to traverse the log file looking for specific info.
On Mon, Jun 04, 2001 at 07:42:38AM -0700, Peter Cornelius wrote:
> According to the docs flock is just an 'advisory' lock. S
On Jun 4, Nichole Bialczyk said:
>i'm curious as to how secure flock is. if the file is locked and another
>user tries to access it, does it wait or does it kick them off? also, is
>it ever possible for it to get stuck?
First, let me tell you that flock() doesn't really pr
--- Nichole Bialczyk <[EMAIL PROTECTED]> wrote:
> i'm curious as to how secure flock is. if the file is locked and
> another user tries to access it, does it wait or does it kick them
> off? also, is it ever possible for it to get stuck?
I think you can set the semantics t
i'm curious as to how secure flock is. if the file is locked and another
user tries to access it, does it wait or does it kick them off? also, is
it ever possible for it to get stuck?
thanks, nichole
--- Peter Scott <[EMAIL PROTECTED]> wrote:
> > A rather clever way to emulate locking is to use mkdir() and
> > rmdir().
> > Although it requires you to create a lock file, it's atomic and
> > safe.
> >
> > sub lock {
> > 1 until mkdir "$_[0].lck", 0777;
> > $locked{$_[0]}++;
> > }
On
course, then the question is... is mkdir() atomic on Win32 Perl.."
>They say that mkdir() is atomic ON A SERVER -- if you're on an NFS, all
>bets are off.
>
>The Perl Cookbook mentions the mkdir+rmdir locking scheme. I
>think that's a pretty safe bet.
actually .
On May 15, King, Jason said:
>>A rather clever way to emulate locking is to use mkdir() and rmdir().
>>
>>Although it requires you to create a lock file, it's atomic and safe.
>
>are you sure ? .. just because it constitutes one Perl statement doesn't
>mean that it's atomic .. I suspect mkdir has
Brian Shoemaker writes ..
>Starting very soon, we'll be changing from Linux to NT.
>
>Currently, at the beginning of programs I use the following
>use Fcntl qw(:flock);
>then later in the scripts I use
>flock(FILE, LOCK_EX);
>
>The Perl 5 book I have says f
Jeff Pinyan writes ..
>On May 14, Brian Shoemaker said:
>
>>The Perl 5 book I have says flock function doesn't work in
>Windows systems.
>>
>>I don't want to create a lock file each time someone accesses
>a file and
>>then have to delete that lock
On May 14, Peter Scott said:
>Ooh, that is clever. Has it been encapsulated in a CPAN module?
No. It can break on NFS.
>> 1 until mkdir "$_[0].lck", 0777;
>
>Perhaps sleep 1 until mkdir would be a little less stressful on the average
>system :-)
Feh. ;)
--
Jeff "japhy" Pinyan [EM
At 06:01 PM 5/14/01 -0400, Jeff Pinyan wrote:
>On May 14, Brian Shoemaker said:
>
> >The Perl 5 book I have says flock function doesn't work in Windows systems.
> >
> >I don't want to create a lock file each time someone accesses a file and
> >then have to
On May 14, Brian Shoemaker said:
>The Perl 5 book I have says flock function doesn't work in Windows systems.
>
>I don't want to create a lock file each time someone accesses a file and
>then have to delete that lock.
A rather clever way to emulate locking is to
>-Original Message-
>From: Brian Shoemaker [mailto:[EMAIL PROTECTED]]
>Sent: Monday, May 14, 2001 4:55 PM
>To: [EMAIL PROTECTED]
>Subject: flock
>
>
>Starting very soon, we'll be changing from Linux to NT.
I am so sorry for you. :-)
>Currently, at the
I'm just reading in the Perl DBI book about flock. It says it works in
Windows NT/2000, just not on Windows 95/98. That's just what I read, haven't
tested it.
> -Original Message-
> From: Brian Shoemaker [SMTP:[EMAIL PROTECTED]]
> Sent: Monday, May 14, 200
Starting very soon, we'll be changing from Linux to NT.
Currently, at the beginning of programs I use the following
use Fcntl qw(:flock);
then later in the scripts I use
flock(FILE, LOCK_EX);
The Perl 5 book I have says flock function doesn't work in Windows systems.
I don't w
ms about creating a temp
>file for a lock on win32(i know win32 doesn't support FLOCK)
>
>these post had a couple of contradictions about them...
>
>does anyone know a stable way to lock a file on win32?
the term "Win32" that you use isn't specific enough .. flo
file for a lock on win32(i know win32 doesn't support FLOCK)
these post had a couple of contradictions about them...
does anyone know a stable way to lock a file on win32?
tx
RDWest
75 matches
Mail list logo