Find the answer to your Linux question:
Results 1 to 2 of 2
Hi. First off, let me say that im pretty new to linux and PHP programming. If you happen to respond, please dont use the most advanced language you can come ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2006
    Posts
    1

    Reading system log from browser


    Hi.
    First off, let me say that im pretty new to linux and PHP programming. If you happen to respond, please dont use the most advanced language you can come up with :=)


    I want to make a PHP script that reads the system log, so that i can access it through my browser. I can read/print files with PHP and get them to show in the browser, but i need to use sudo in order to read the system log.

    This is the script i use to read/print a log file that is just in the root dir: How do i "fix" it so it can read a file that the browser dont have rights to ?

    <?php $fp = @fopen("log.txt", "rb") or die("Couldn't open the log");
    $data = fread($fp, filesize($fp));

    while(!feof($fp))
    {
    $data .= fgets($fp, 1024);
    }
    ehco <pre>;
    echo $data;
    echo </pre>;
    ?>

  2. #2
    Linux Guru kkubasik's Avatar
    Join Date
    Mar 2004
    Location
    Lat: 39:03:51N Lon: 77:14:37W
    Posts
    2,396
    In short, you can't... thats the point of permissions....

    You could use group permissions to just allow the server read permissions. But if you just want to view logs online, check out something like webmin. Or better, just have a cron job do it nightly.....
    Avoid the Gates of Hell. Use Linux
    A Penny for your Thoughts

    Formerly Known as qub333

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •