home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!uwm.edu!linac!att!cbnewsc!cbfsb!att-out!rutgers!carssdf!watson
- From: watson@carssdf.UUCP (- Self Empl. Sys.Integrator)
- Newsgroups: comp.lang.perl
- Subject: Re: perl lockf
- Message-ID: <406@carssdf.UUCP>
- Date: 8 Nov 92 14:16:08 GMT
- References: <1992Nov6.220846.12955@cs.brown.edu>
- Reply-To: watson@carssdf.UUCP (John Watson -- Self Empl. Sys.Integrator)
- Organization: John Watson (Self Employed System Integrator)
- Lines: 18
-
- In reply to errors locking file etc...
-
- I had a problem locking printers till I discovered that I had to have
- read priv. to lock the device, so now I open with "+>", sample follows:
- I include this with do 'openpf.ph' statement. (predates require).
-
- $pfile_nm = $ENV{'RPTPRN'};
- if ($pfile_nm =~ /^[.\/]/) {
- open (PF,"+>$pfile_nm") || die "\n Printer is in use. \n";
- $lockit = pack('s2l2s2',1,0,0,0,0,0);
- fcntl(PF,6,$lockit) || die "\n Printer is in use. \n";
- } else {
- if ($pfile_nm =~ /^[^|]/) { $pfile_nm = '|lp -s -d'.$pfile_nm; }
- open(PF,"$pfile_nm") || die "\n Unable to open spooled printer ($pfile_nm) \n";
- }
- select(PF);
-
- --------- end --------
-