From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96078608810111.tru64-unix-managers.marc@archive.invalid> From: Brian Sherwood Date: Wed, 05 Feb 1997 14:56:38 +0000 To: tru64-unix-managers Subject: SUMMARY: How to: File locking with perl X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96078608810111 Thanks to all that replied. I ended up using peices of a script from Eric Z. Ayers to create the following small test program. I was using "sslli" for my flags to pack. Eric's "ssiii" worked much better. Something strange though, I could not get the "open" to open a file read/write without first truncating it. I had to use "sysopen". #!/usr/local/bin/perl use Fcntl; use POSIX; $INFILE="qwqwqwqw"; $flags="ssiii"; $s_flock = pack ($flags,F_WRLCK,SEEK_CUR,1,0,0); @ary=unpack $flags,$s_flock; print "@ary\n"; sysopen (INFILE,$INFILE,O_RDWR|O_EXCL) or die "sysopen infile"; fcntl (INFILE,F_SETLKW,$s_flock) or die "fcntl:$!:"; print "After fcntl\n"; $ttt=; seek (INFILE,0,SEEK_END); print INFILE $ttt; close (INFILE); ------------------------------------------------------- Brian Sherwood E-mail: sherwood@esu.edu Network Administrator Phone: 717-422-3299 East Stroudsburg University East Stroudsburg PA 18301