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( ) > { > unless (flock LOCKFILE, LOCK_EX|LOCK_NB) { > warn "File $lo

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
Dermot wrote: Hi, Hello, I have a cgi script that writes to a disk file. It would be safest if I can get an exclusive lock on the file. I had a look at the opentut and believe I have followed that the example there. Here's what I have sysopen my $fh, $file_path, O_WRONLY || die "can't open $

Re: flock - exclusive file locking

2008-03-17 Thread Gunnar Hjalmarsson
Dermot wrote: I have a cgi script that writes to a disk file. It would be safest if I can get an exclusive lock on the file. I had a look at the opentut and believe I have followed that the example there. Here's what I have sysopen my $fh, $file_path, O_WRONLY || die "can't open $

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

Re: flock question

2007-06-11 Thread Chas Owens
On 6/11/07, oryann9 <[EMAIL PROTECTED]> wrote: snip If you use LOCK_NB and are refused a LOCK_SH, then you know that someone else has a LOCK_EX and is updating the file. If you are refused a LOCK_EX, then someone holds either a LOCK_SH or a LOCK_EX, so you shouldn't try to update the file. snip

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

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 txt file. > > To up d

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..."; } if(!defined $rc) { die "Co

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..."; } > if(!defined $rc) { die "Could not get lock no

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 the lock (check the return status to se

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 > (check the return status to see if you got it).

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 file (such as when deleting a record). > > s

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. > > > Do you know mechanism like fl

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 be > configured to us

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 experiencing some problems using user_manage > v1.53

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, and try 10 t

Re: flock() question

2001-10-30 Thread Pete Sergeant
look in to the alarm() function perldoc -f alarm +Pete -- [EMAIL PROTECTED] ;;($_='Yw_xUabcdtefgdijktljkotiersjkUzxT yvlkbfdtcierstajogvPruntRshackRJelov')=~ y&/RTUv;wxYz$&/ ~'/;$=();$&&&eval&&print <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi, > > I'

Re: flock

2001-06-04 Thread Mathew Hennessy
Paul wrote: > > One option is to rename the logfile temporarily. Have the script call > it something like LogTemp$$ or something ($$ is the PID of the current > job). Then it doesn't *exist* in it's previous name. Move it back to > the original filename when you're done. If you have admi

Re: flock

2001-06-04 Thread Paul
One option is to rename the logfile temporarily. Have the script call it something like LogTemp$$ or something ($$ is the PID of the current job). Then it doesn't *exist* in it's previous name. Move it back to the original filename when you're done. There are problems with that, too, though, suc

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 use perl's flock

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 to lock a log f

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. So it only works as >

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 produce "file locking"

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 to wait, or return an im

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
Jeff .. you wrote .. >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 i

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 flock function doesn't work in >Windows

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. > >A rather clever way to emulate locking is

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 delete that lock. > >A rather clever way

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 use mkdir() and rmdir(). Althoug

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 beginning of programs I use the foll

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, 2001 2:55 PM > To: [EMAIL PROTECTE

RE: flock for win32

2001-05-01 Thread King, Jason
RDWest writes .. >i just joined the list. i've been fooling with perl scripts for a >few months now. just installing and editing html output mainly... now >i'm studying a coupkle books to write my own (i hope) > >question: i've seen a couple post in some forums about creating a temp >file for