SkÃ¥ne Sjælland Linux User Group - http://www.sslug.dk Forside   Tilmelding   Postarkiv   Forum   Kalender   Søg
MhonArc Dato: [Date Prev] [Kronologisk oversigt] [Date Next]   TrÃ¥d: [Date Prev] [Oversigt trÃ¥de] [Date Next]   MhonArc
 

Re: [PERL] Manglende fil: lock.pl



Jeppe Uhd Jepsen wrote:
> 
> Davs.
> 
> Jeg har et lille problem med en web-counter jeg har fundet. Når jeg
> eksekverer scriptet, spytter den lidt sjov ind i log'en:
> 
> Can't locate lock.pl in @INC at /var/lib/httpd/cgi-bin/count_abacus.pl
> line 59.
> [Fri Jan 15 10:29:01 1999] access to
> /var/lib/httpd/cgi-bin/count_abacus.pl failed for 193.89.221.2, reason:
> Premature end of script headers
> 193.89.221.2 - - [15/Jan/1999:10:29:01 +0100] "GET
> /cgi-bin/count_abacus.pl HTTP/1.0" 500 391
> 
> Hvor finder jeg omtalte lock.pl
> 
> MVH Jeppe Uhd Jepsen


Vilken counter använder du ?

Version 1: lock.pl ================================
#-------------------------------------------------
# lock.pl
# Copyright (C) 1995 Jonathan A. Lewis
#
# Permission to use, copy, modify, and distribute this include file and
its 
# documentation for any purpose without fee is granted
# provided that the above copyright notice appears in all copies.
# 
# This, and the accompanying scripts, is provided "as is" without any
express 
# or implied warranty.
#
# Use this script at your own risk.  It's guaranteed to do nothing but
# occupy space...unless your disk crashes, in which case it does nothing
# at all.
#------------------------------------------------


$LOCK_SH = 1;
$LOCK_EX = 2;
$LOCK_NB = 4;
$LOCK_UN = 8;

sub lock {
  #pass in a file handle to be locked
  #flock will wait until it can get a lock
        
        flock($_[0], $LOCK_EX);
        # seek to whence just incase we were waiting for a lock after
opening
        seek($_[0], 0, $_[1]);
}

sub unlock {
        flock($_[0], $LOCK_UN);
}
1; #return true        


===================================================

Version 2: lock.pl ================================
use Fcntl;

sub lockfile {
  local($FILE) = @_;

  local($lock) = pack('s s l l s', &F_WRLCK, 0, 0, 0, 0);
  return fcntl($FILE, &F_SETLK, $lock);
}


sub unlockfile {
  local($FILE) = @_;

  local($unlock) = pack('s s l l s', &F_UNLCK, 0, 0, 0, 0);
  return fcntl($FILE, &F_SETLK, $unlock);
}


sub make_nonblocking {
  local($FILE) = @_;

  local($flags) = fcntl($FILE, &F_GETFL, 0);
  $flags &= ~(O_NDELAY | O_NONBLOCK);
  $flags |= O_NDELAY;
  fcntl($FILE, 4, $flags);
# fcntl($FILE, &F_SETFL, $flags);   # If there's a problem,
                                    # try this line instead.
}

1;
===================================================

Det mesta av detta står i kamelbibeln s.166-167, eller i kokboken
s.245-247.

				/Henrik


 
Forside   Tilmelding   Postarkiv   Oversigt   Kalender   Søg

 
 
Henvendelse vedrørende websiderne til <www_admin>. Senest ændret 2005-08-10, klokken 19:51
Denne side vedligeholdes af MHonArc .