Re: flock related problem

2008-11-28 Thread Chas. Owens
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( ) > {

flock related problem

2008-11-27 Thread Anirban Adhikary
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

Re: flock - exclusive file locking

2008-03-18 Thread Chas. Owens
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(),

Re: flock - exclusive file locking

2008-03-17 Thread John W. Krahn
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

Re: flock - exclusive file locking

2008-03-17 Thread Gunnar Hjalmarsson
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

Re: flock - exclusive file locking

2008-03-17 Thread Dr.Ruud
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

flock - exclusive file locking

2008-03-17 Thread Dermot
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);

Re: flock question

2007-06-11 Thread Chas Owens
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

flock question

2007-06-11 Thread oryann9
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

Re: flock & network

2005-10-13 Thread Peter Scott
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

Re: flock & network

2005-10-13 Thread Xavier Noria
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

Re: flock & network

2005-10-13 Thread Tom Allison
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

Re: flock & network

2005-10-12 Thread John Doe
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

flock & network

2005-10-12 Thread Tom Allison
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

Re: flock and open files

2005-07-14 Thread mgoland
- 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

flock and open files

2005-07-14 Thread bclark1
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

Re: MySQL and flock

2004-12-15 Thread Jay
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

RE: MySQL and flock

2004-12-15 Thread Ron Goral
> -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 &

Re: MySQL and flock

2004-12-14 Thread Octavian Rasnita
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

RE: MySQL and flock

2004-12-14 Thread Ron Goral
> -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

A question about flock()

2004-12-13 Thread Shu Hung (Koala)
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

MySQL and flock

2004-12-13 Thread Octavian Rasnita
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

Re: A question about flock()

2004-12-13 Thread Tor Hildrum
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

Re: flock return value / bit wise or'd LOCK_NB

2004-04-07 Thread JupiterHost.Net
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...";

Re: flock return value / bit wise or'd LOCK_NB

2004-04-07 Thread Smoot Carl-Mitchell
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..."; } >

Re: flock return value / bit wise or'd LOCK_NB

2004-04-07 Thread JupiterHost.Net
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

Re: flock return value / bit wise or'd LOCK_NB

2004-04-07 Thread Smoot Carl-Mitchell
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 &

flock return value / bit wise or'd LOCK_NB

2004-04-07 Thread JupiterHost.Net
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

Re: flock() semantics?

2003-10-30 Thread Rob Dixon
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

flock() semantics?

2003-10-30 Thread Shaun Fryer
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

Repost : Using Flock under IRIX, Solaris and Linux with Perl

2003-09-09 Thread James Amrhein
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

Flock under IRIX, Solaris and Linux

2003-08-14 Thread James Amrhein
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

Re: checking OS support for flock

2003-06-27 Thread Wiggins d'Anconia
[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

checking OS support for flock

2003-06-27 Thread Motherofperls
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.

Re: open(IN,) flock?

2003-06-02 Thread Tassilo von Parseval
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

Re: open(IN,) flock?

2003-06-02 Thread Rob Dixon
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

Re: open(IN,) flock?

2003-06-02 Thread Rob Dixon
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 >

open(IN,) flock?

2003-06-02 Thread Bob's Demise
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 -

Checking for open files with flock

2003-02-05 Thread Lewis, Michael (TBS-TTS)
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))) {

Re: flock problem

2002-11-11 Thread Sudarshan Raghavan
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. >

flock problem

2002-11-11 Thread Nisim, Amit
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 flock give Bad file number?

2002-03-29 Thread Ahmed Moustafa
Why does exclusive flock give Bad file number (Solaris)? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Help understanding DB_File and flock

2002-03-18 Thread Jenda Krynicky
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.

Help understanding DB_File and flock

2002-03-18 Thread Jay M
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";

flock() failure - possible Perl compile problem?

2002-02-08 Thread Richard Smith
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.

Re: flock with nfs

2002-02-06 Thread Alain
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

flock with nfs

2002-02-06 Thread Alain
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

RE: flock problem on AIX 4.3.3

2001-11-20 Thread Bob Showalter
> -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

flock problem on AIX 4.3.3

2001-11-20 Thread Rich Fernandez
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

Re: flock() question

2001-10-31 Thread Luke Bakken
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,

Re: flock() question

2001-10-30 Thread Pete Sergeant
[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

flock() question

2001-10-30 Thread documents
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

RE: Speaking of flock......

2001-06-04 Thread Peter Cornelius
> > 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

Speaking of flock......

2001-06-04 Thread Brian Shoemaker
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: flock

2001-06-04 Thread Mathew Hennessy
;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

Re: flock

2001-06-04 Thread Paul
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, >

Re: flock

2001-06-04 Thread Christian Campbell
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

Re: flock

2001-06-04 Thread Peter Cornelius
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

Re: flock

2001-06-04 Thread Nichole Bialczyk
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

Re: flock

2001-06-04 Thread Jeff Pinyan
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

Re: flock

2001-06-04 Thread Paul
--- 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

flock

2001-06-04 Thread Nichole Bialczyk
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

Re: flock

2001-05-15 Thread Paul
--- 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

RE: flock

2001-05-14 Thread King, Jason
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 .

RE: flock

2001-05-14 Thread Jeff Pinyan
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

RE: flock

2001-05-14 Thread King, Jason
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

RE: flock

2001-05-14 Thread King, Jason
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

Re: flock

2001-05-14 Thread Jeff Pinyan
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

Re: flock

2001-05-14 Thread Peter Scott
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

Re: flock

2001-05-14 Thread Jeff Pinyan
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

RE: flock

2001-05-14 Thread Brett McCoy
>-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

RE: flock

2001-05-14 Thread John Peterson
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

flock

2001-05-14 Thread Brian Shoemaker
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

RE: flock for win32

2001-05-01 Thread King, Jason
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

flock for win32

2001-04-30 Thread RDWest
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