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, such as if someone
re-creates the original name. What to do with the new one?

I'd say rename, then write a standard "NOBODY HOME" version and set the
permissions to 000 (you're using *NIX, aren't you?). When ready, delete
the 000 version and move the original 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,
> 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 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
> > > long as everyone checks the file with flock before working with
> it, so it's
> > > not very secure.  The point of flock is to keep several programs
> from
> > > clobbering each others data so I don't think using it as a
> security feature
> > > will work well.  What are you trying to do?
> > >
> > > Peter C.
> > >
> > > 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?
> also, is
> > > > it ever possible for it to get stuck?
> > > >
> > > > thanks, nichole
> > >
> 


=====
print "Just another Perl Hacker\n"; # edited for readability =o)
=============================================================
Real friends are those whom, when you inconvenience them, are bothered less by it than 
you are. -- me. =o) 
=============================================================
"There are trivial truths and there are great Truths.
 The opposite of a trival truth is obviously false.
 The opposite of a great Truth is also true."  -- Neils Bohr

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

Reply via email to