I have a shell file and I am trying to show the live update output of the shell script to the user on the webpage.
The following is my sample shell script.
while true
do
echo "Hi"
sleep 1
done
Below is my Node JS.
var http = require('http');
var fs = require('fs');
const PORT=8080;
fs.readFile('./splitter.html', function (err, html) {
if (err) throw err;
http.createServer(function(request, response) {
response.writeHeader(200, {"Content-Type": "text/html"});
response.write(html);
response.end();
}).listen(PORT);
});
And this is HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="public/css/style.css">
<link rel="stylesheet" href="public/css/splitter.css">
</head>
<body>
<form>
<label for="folderPath">Folder Path:</label>
<input type="text" id="folderPath" name="folderPath">
<br></br>
<fieldset id="bit">
<p>Please Choose Khz: </p>
<input type="radio" value="8bit" name="bit"> 8bit<br>
<input type="radio" value="16bit" name="bit"> 16bit <br>
</fieldset>
<br></br>
<fieldset id="audio-type">
<p>Please Choose Type: </p>
<input type="radio" value="C12" name="group2"> C12 <br>
<input type="radio" value="LR" name="group2"> LR <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;">
<!---I want to show the live update output here-->
</div>
</body>
</html>
And within the box, where I commented How do I run the shell script when the user hits submit and show the user the live output of the shell command? Within the box so it doesn't overflow.
Aucun commentaire:
Enregistrer un commentaire