I'm not sure why I get the error above, but is there a way to wait to unlink a file until it's no longer being used by another process?
IIn a CGI file, when trying to unlink a file I get the following message. "The process cannot access the file because it is being used by another process" What I'm doing is: basically I'm reading file 1 and writing it to file 2. close file 1 close file 2. rename file 2 to file 1. Since I can't rename if the file exists, I first unlink file 1. When I do, I get the error above. I've closed the file, and It's not open anywhere else so I don't understand what the problem is. What's odd is that this code runs fine if I run it as a command line script, but if it's run as a CGI script if fails. Here's the relevant code: read file 1. write file 2. close (RIGHTSLISTFILE); close (TMPFILE); # rename tmpfile to rightslistfile $a = stat($tmpfilename); $b = stat($rightslistfilename); printf "perms: %04o\n<br>", $a & 07777; printf "perms: %04o\n<br>", $b & 07777; if ( ! unlink( $rightslistfilename )) { print "Unlink ERROR!<br>"; print "$tmpfilename<br>"; print "$rightslistfilename<br>"; print "$!<br>"; print "$^E<br>"; } if( ! rename $tmpfilename, $rightslistfilename ) { print "Rename ERROR!<br>"; print "$tmpfilename<br>"; print "$rightslistfilename<br>"; print "$!<br>"; print "$^E<br>"; system("whoami"); print "<br>"; } Thanks. Ed -- Ed -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>