1

I am trying to get the output of the command to be displayed on the clients browser as the actual command runs, so far it successfully completes the command and then all the relevant output is displayed. However, as this can take up to 30 seconds i'd like the ongoing output that would appear on the shell screen to be forwarded in real time to the browser. The command should be started by the press of a button.

The Button

<div class="inner"><form action="" method="post">
<button type="submit" name="button5">Update Game Server</button>
</form>

</div>

The code to run the system command

<?php
if (isset($_POST['button5'])) {
chdir('/home/aname/steamcmd/');
echo '<br></br>';
echo '<pre>';
echo shell_exec ('./steamcmd.sh +logon aname apass +app_update validate +quit');
echo '</pre>';} ?>

I have seen similar posts where people have suggested using passthru(), popen(), ob_flush() & flush() however, if I use these options instead of system_exec() they don't update the page, they once again only show the completed output in the browser once the entire process has been completed.

I suspect the way I am implementing the button may be more of an issue than the way the command is actually being sent to the system but not sure what to try.

Apache/2.4.29 , CentOS 7, PHP version: 5.6.30

bobbyfour
  • 23
  • 3
  • Possible duplicate of [PHP reading shell\_exec live output](https://stackoverflow.com/questions/20107147/php-reading-shell-exec-live-output) – Evil_skunk Jul 04 '18 at 19:24
  • I've already tried the suggestions from that post you refer to as a possible duplicate , using passthru and the while loops, it didn't change the behavior, the browser still only displays the output after the command has finished. I even substituted my steamcmd command for the ping command on that page just in case it was the command causing the issue. – bobbyfour Jul 04 '18 at 19:37
  • I also added the code from that answer directly on it's own without the need to press a button, the result is the same, I only see browser output once all commands have actually finished. – bobbyfour Jul 04 '18 at 19:49

0 Answers0