home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / perl / 6900 < prev    next >
Encoding:
Internet Message Format  |  1992-11-08  |  1.1 KB

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