0

I want a webpage to reflect a log file. I have a bash script that converts the log to html. Currently this runs periodically via crontab, which works, but obviously executions are redundant when the webpage isn't viewed. I'd like to implement a system so the bash script runs only called when the webpage is called.

I gather an index.php script along the lines:

<?php
$message=shell_exec(". /path/script.sh");
?>

.. should generate the index.html file ok. But is there an easy way to get index.php/Apache to serve that file to the client browser?

2
  • 1
    Why not use [a modified version of] your bash script as a CGI instead of a PHP proxy?
    – user86969
    Commented Apr 30, 2015 at 16:25
  • The title does not accurately reflect your question. You are not talking about a static index.html file (for which the answer would be some of linking or redirection).
    – Kapil
    Commented Apr 30, 2019 at 3:37

3 Answers 3

1

I suppose you could use readfile to dump the file you've just created towards the browser. Alternatively, you could issue a 302 temporary redirect to index.html.

0

I gather the best solution is to end the php with:

header('Location: index.html');
exit;
0

Another option:

Create an .htaccess file in your web server root with the following:

AddType application/x-httpd-php .htm .html

Now apache will process .htm and .html files as php documents and any <?php ... ?> tags located in that file will be interpreted as php.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .