I am trying to get a live output (when a line appears in the window, it should appear on the server as well) of a terminal window on Ubuntu 16.04. I have various needs for this to work. I am first off trying to get 'sudo apt-get update' to be executed by an HTML button and the terminal output to be received live in the client browser... I've trying using flush() and what-not but cannot seem to get it to work... Any PHP specialists willing to help out here? Thank you!
Here is what I currently have:
<html>
<head>
    <meta charset="UTF-8">
    <title>Censored</title>
</head>
<body>
    <?php
    echo
    "<form action='' method='post'>
    <input type='submit' name='command' value='Network Properties' />
    </form>";
    if(isset($_POST['command']))
    {
        $cmd= shell_exec('ifconfig -a');
        echo '<pre>$cmd</pre>';
    }
    echo
    "<form action='' method='post'>
    <input type='submit' name='update' value='apt-get update' />
    </form>";
    if(isset($_POST['update']))
    {
          echo '<pre>';
          flush();
            $output = system('sudo apt-get update');
          echo '</pre>';
    }
    ?>
</body>
 
    