CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Locking a script on win32 Perl

 



Warren Bell
Deleted

Feb 11, 2000, 8:00 PM

Post #1 of 3 (891 views)
Locking a script on win32 Perl Can't Post

Is there a way to lock a whole script on a Windows machine? So that if somthing else tries to start it, it will just die? I've tried doing it with flock but I don't know if I'm doing it right or if windows perl even supports it.

It doesn't have to be pretty, just a quick way to lock the script.

Thanks


Cure
User

Feb 12, 2000, 12:43 PM

Post #2 of 3 (891 views)
Re: Locking a script on win32 Perl [In reply to] Can't Post

Hi Warren Bell

ActivePerl does not support the flock funciton.

You don't need the flock function on a Windows Platform because Windows only allows one user at a time to access a file.

Cure


Warren Bell
Deleted

Feb 12, 2000, 12:58 PM

Post #3 of 3 (891 views)
Re: Locking a script on win32 Perl [In reply to] Can't Post

Thanks for the reply but I figured it out using this at the beggining of the script:

$lock = 'mail.lock';

open(LCK,">$lock") if ! open(LNK,"$lock") | | exit;
print LCK "0";
close(LCK);

And this at the end:

system("del $lock");

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives