I wrote an HTML page with JavaScript, a PHP file and a shell script
they are all on the same machine
I run the shell script, it will open the html page with Firefox,
when the JavaScript finishes, it will POST to a getdata.php
<form id="hidden_form" method="POST" action="getdata.php" ></form>
The getdata.php will do something and then it will send a signal to the shell script
the above is the normal behaviour, I’m afraid at some time, the PHP or JavaScript run into error and don’t send signal to the shell script
are there any good and simple way for shell script to detect whether JavaScript is running?
a guy below mentioned that I can let javascript send request to the server periodically, like once every 2 minutes, but how to let shell script notice this/get the signal?
As someone suggested, you can poll the server with setInterval to see if the javascript engine is still running, but that might as well mean that only the javascript thread doing setInterval is the one actually running (depending on what kind of error could arise). You could do the post to “status.php” which would touch/write to a file on the disk, which the bash script could poll to see if it’s updated in regular intervals.
I’d however suggest that you look into something like phantomjs which allows you to solve these kind of problems.