Loading ...
Sorry, an error occurred while loading the content.
 

viewing log files

Expand Messages
  • tomroth@wfubmc.edu
    Hi, I have a script that writes to a log file like this: open(LOG, $logfile ); print LOG $tries | $name downloaded $filename $logline n ;
    Message 1 of 1 , Feb 1, 2001
      Hi,

      I have a script that writes to a log file like this:


      open(LOG,">>$logfile");
      print LOG "$tries | <b>$name</b> downloaded <b>$filename</b> $logline\n";
      close(LOG);
      chmod(0666, $logfile);


      Then I have another script that allows me to view that log file from my
      web browser.


      $logfile = "/export/home/dmaster/secure/auth.log";
      $log = &Template("$logfile");

      ...a bunch of html to make it look nice and then...

      <pre>
      $log
      </pre>


      Question 1:
      The script works great except the most recent log entry goes to the
      bottom of the logfile. What I'd really like is for it to go to the top.
      Is there any way to do that?


      Question 2:
      In this same script I created a way to purge the whole logfile simply by
      doing this:

      open (FH, ">$logfile") || &error("Unable to open auth.log");
      close FH;

      $log = &Template("$logfile");

      Now it's an empty file. It's crude but it works. However, what I'd
      really like to do is to remove just the first 10 lines (or the last 10
      lines if I can reverse the entry order) so that some of the logfile
      still remains. Any ideas?


      Thanks in advance!

      --
      Tom Roth • tomroth@... • tel 336.716.4493
      Wake Forest University School of Medicine
      Dept of Biomedical Communications
      Medical Center Blvd • Winston-Salem, NC 27157-1011
      http://www.wfubmc.edu/biomed/
    Your message has been successfully submitted and would be delivered to recipients shortly.