I have a shell file shell.sh that echo hi every 1 second. I would like to display the real time output of my shell script on my website in a box.
However, the problem is that, my code doesn't show the output in a box. And when I click on it, everything disappears and I just see a white page.
The following is my php file.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form method="GET" action="splitter.php">
<label for="folderPath">Folder Path:</label>
<input type="text" id="folderPath" name="folderPath">
<br></br>
<fieldset id="khz">
<p>Please Choose Khz: </p>
<input type="radio" value="8khz" name="khz"> 8khz <br>
<input type="radio" value="16khz" name="khz"> 16khz <br>
</fieldset>
<br></br>
<fieldset id="audio-type">
<p>Please Choose Type: </p>
<input type="radio" value="C12" name="group2"> Channel 1 & 2 <br>
<input type="radio" value="LR" name="group2"> Left to Right <br>
</fieldset>
<div class="spaceh10"></div>
<input class = "submitButton" type="submit" value="Submit">
<div class="spaceh10"></div>
<div style="width:500px;height:100px;border:1px solid #000;">
<?php
if (isset($_GET['folderPath']) && !empty($_GET['folderPath']) &&
isset($_GET['khz']) && isset($_GET['group2'])) {
$folderPath = $_GET['folderPath'];
$khz = $_GET['khz'];
$group2 = $_GET['group2'];
#$folderPath $khz $group2
$command = './shell.sh';
while (@ ob_end_flush()); // end all output buffers if any
$proc = popen($command, 'r');
echo '<pre>';
while (!feof($proc)){
echo fread($proc, 4096);
@ flush();
}
echo '</pre>';
}
?>
</div>
</body>
</html>
and below is my shell script
while true
do
echo "Hi"
sleep 1
done
How do I make my code run in the box? And make sure the outputs just stay in the box and doesn't overflow. Why doesn't my code show the output?
I am monitoring the server address which my php file is running. And when I click submit it loads forever on a white screen and since I know it's not gonna end I stop within the browser. and I get the following error.
./shell.sh: line 6: echo: write error: Broken pipe
How can I show my real time shell output in a box? and it doesn't outflow the box border?