Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 177
  • Last Modified:

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.
0
Lee5
Asked:
Lee5
  • 5
  • 3
1 Solution
 
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
 
ozoCommented:
yes, can't you open a file?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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:
Just keep an exclusive flock on a file over the entire script.
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now