
yim11
Novice
Jun 7, 2001, 7:00 PM
Post #1 of 3
(168 views)
|
|
Flock and windows
|
Can't Post
|
|
Hello, I have a script I need to use that utilizes the flock funtion. I understand that the activestate perl install on windows does not use the flock command, my question is does anyone know a way to get around this or to allow the use of flock on a windows machine? The section of code that uses flock is posted below. TIA for all help! --------begin code section-------- sub read_pwd_file { if($pwdfile eq ""){ &send_error("503"); #failed to locate the password file exit; } #open password file unless(open(PWD,$pwdfile)){ &send_error("504"); #failed to open the password file exit; } flock(PWD,$LOCK_EX); seek(PWD,0,0); while(<PWD>){ if (index($_,":") >= 0){ ($cuser,$cpwd) = split(':',$_); chop($cpwd); if($users{$cuser} ne ""){ &send_error("Duplicate user '" . $cuser . "' found\n"); exit; } $users{$cuser}=$cpwd; } } flock(CFG,$LOCK_UN); close(CFG); return %users; } <--snip--> sub write_pwd_file { if($pwdfile eq ""){ &send_error("503"); #failed to locate the password file exit; } #open password file unless(open(PWD,">" . $pwdfile)){ &send_error("504"); #failed to open the password file exit; } flock(PWD,$LOCK_EX); seek(PWD,0,0); foreach $user (keys %users){ $temp = $temp . $user . " :: " . $users{$user} . "\n"; print PWD $user . ":" . $users{$user} . "\n"; } flock(PWD,$LOCK_UN); close(PWD); } -------end code section----------
|