Solved

Lock out other users of script

Posted on 1998-10-19
8
161 Views
Last Modified: 2010-03-05
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
Comment
Question by:Lee5
  • 5
  • 3
8 Comments
 
LVL 84

Expert Comment

by:ozo
Comment Utility
Doesn't a flock at the start of your script do what you want?
0
 

Author Comment

by:Lee5
Comment Utility
ozo
It is my understanding that flock only works on open files.
0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
yes, can't you open a file?
0
 

Author Comment

by:Lee5
Comment Utility
  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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 84

Expert Comment

by:ozo
Comment Utility
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
 

Author Comment

by:Lee5
Comment Utility
ozo
make it an answer
Thanks,
0
 
LVL 84

Accepted Solution

by:
ozo earned 50 total points
Comment Utility
Just keep an exclusive flock on a file over the entire script.
0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
MySQL Web Database 5 105
How to have Perl return value to an Ajax call 17 248
Perl Tutorial 6 125
PERL get the value for query 4 139
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now