View Full Version : interaction among javascript, shell and php

11-07-2012, 12:32 AM
I create a html page with some javascript inside, and a php script(getdata.php) I put them on a local apache server

I have written a shell script to:

start tcpdump and then open the local html page with firefox. The javascript will download a bit javascript api source from Internet and keep on running until it detect an event. When the javascript detects the event, it uses a hidden form to post the data to that php script

<form id="hidden_form" method="POST" action="getdata.php" ></form>

the php script will then process the data and write some files.

there is a key string in the html page, and I want to change it for many times with different strings. These different strings are kept in a string file as lines.

So after the php script write the files, I need: the tcpdump process and firefox process will be killed, the key string in the html page will be modified and the above process is repeated again.

So there will be a loop until all the lines from the string file are read and used. I'm at a loss on how to do this

my concerns are:

1 the big problem is, if there is something wrong with the javascript(e.g, it can't download that bit src javascript due to temporal network problem , it won't continue to run), or there is something wrong with the php script, then the loop will be broken

2 my idea is: a shell script repeats the initiation of each loop: modify the html page, starts tcpdump and firefox, and then it is blocked until A) the php script finishes writing files and signal the shell script to unblock and continue to the next loop B) the shell script detect that neither the php script nor javascript isn't running, so there should be something wrong with them. but I'm at a loss on how to implement A) and B)