Lock out other users of script

I have a script called by form on html.  I would like to lock out any other user from accessing that script while another person is accessing it.  I have flock on the files, but need to lock out the whole script when in use.  Perl is running on a unix system.
Lee5Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
ozoConnect With a Mentor Commented:
Just keep an exclusive flock on a file over the entire script.
0
 
ozoCommented:
Doesn't a flock at the start of your script do what you want?
0
 
Lee5Author Commented:
ozo
It is my understanding that flock only works on open files.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
ozoCommented:
yes, can't you open a file?
0
 
Lee5Author Commented:
  yes, but as soon as I close the file the flock leaves.  I also understand that flock is only for that file.  Some of my scripts open and close several files, sometimes a couple of times.  If one person starts a sequence and another can come and operate on the same variables, it could cause a mess.
I am looking for a way to prevent someone from accessing the script if it is being used.  
    I guess I could have a fake file that is opened and flocked at the beginning of the script and then closed at the end.  If the file is not accessible, it could send a message to try later.   Is that what you had in mind?
    If that is so, just make it an answer to my question.
0
 
ozoCommented:
So, don't close the file until the script is done.
Or don't close the file at all, and let it unlock when the script exits.
0
 
Lee5Author Commented:
ozo
make it an answer
Thanks,
0
 
ozoCommented:
You may want to make it a LOCK_NB, so you can test it and give an error message, instead of making the user wait.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.