Я хочу подключиться к файлу «server.js» нажатием html-кнопки.
В файле «server.js» выполняется файл «bash.sh» с использованием shell.js
Может кто-нибудь дать какие-нибудь идеи или указания о том, как действовать?
button.html
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Click me</button>
<p id="demo"></p>
<script src="server.js"></script>
</body>
client.js
function myFunction() {
document.getElementById("demo").innerHTML = "Hello World";
}
server.js
const shell = require('shelljs');
shell.exec('./bash.sh')
bash.sh
#!/bin/bash
printf "command 1 is running...\n\n"
mlpack_linear_regression --training_file aircon.csv -v -M lr.xml
printf "\ncommand 2 is running...\n\n"
mlpack_linear_regression --training_file aircon.csv --test_file
predict.csv --output_predictions_file prediction.csv -v
printf "\nPredicted Output: \n\n"
cat prediction.csv # after this command the result should shown on
#the browser screen
echo "hello" >> file # To test if connection is happening or not
#by writing a string in a file