PHP Execute BASH: echo $output LIVE

General discussions related to php

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 2
Joined: Fri Jun 15, 2012 5:58 am

PHP Execute BASH: echo $output LIVE

Postby tmaiden » Fri Feb 21, 2014 6:25 pm

I'm having the worst trouble trying to understand why I cannot print out BASH commands as they happen.

Here is my code:

Code: Select all

echo "" > /home/owner/scripts/new.txt
ping -c 4 >> /home/owner/scripts/new.txt
echo "FINISHED" >> /home/owner/scripts/new.txt


Code: Select all

        echo "Pre shell_exec<br/>";
        shell_exec("sh /home/owner/scripts/ > /dev/null 2>/dev/null &");
        echo "Post shell_exec<br/>";

        echo "start while<br/>";
        while ($output !== "FINISHED" . chr(10) . "") {
//              ob_implicit_flush(true);
                $output = shell_exec("tail -1 /home/owner/scripts/new.txt");
                echo "". $output . "<br/>";
        echo "end while<br/>";

        echo "<pre>End of PHP Script</pre>";

Any help would be greatly appreciated!

Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 1 guest