PERL   100
webhits log path
Guest on 12th February 2023 10:44:39 AM


  1. #!/usr/bin/perl
  2.  
  3. # reads in apache (or any) logfile and returns either 0 or number of lines
  4. $lines = 0;
  5.  
  6. unless ($ARGV[0]) {
  7.         $log_path = '/var/log/httpd/access_log';
  8. } else {
  9.         $log_path = $ARGV[0];
  10. }
  11.  
  12.  
  13. if (-r $log_path) {
  14.         open(LOG_PATH,$log_path);
  15.         while (<LOG_PATH>) {
  16.                 $lines++;
  17.         }
  18.         close(LOG_PATH);
  19. }
  20.  
  21. print $lines;

Raw Paste

Login or Register to edit or fork this paste. It's free.