Al283
asked on
CGI script doesn't wait for shell script to be executed
The webpage (index1.html)
I have a well-know problem: instead o reloading the gif-image only, I have to reload the whole page since cgi script leaves the original page, which is not desired.
To circumvent this problem, I split the webpage (index2.html) into 2 frames
This way I don't have to reload the whole main.html, but just reload the picture only by using onclick javascript function.
The problem is that in this case the javscript function does not wait for the script creating the new pic.gif and redraws the old gif image.
How to force pic.gif on main.html to be renewed only after it is created by the cgi-script, and not before?
I would appreciate a solution without references to Perl and AJAX and not longer than 5 lines of code. Bash, javascript or c++ are preferred. I strongly believe that a simple solution exists.
<html>
<body>
<img src="pic.gif">
<form action="../cgi-bin/update_pic1.cgi" method="get">
<input type=submit value="Update Pic">
</form>
</body>
</html>
consists of a gif image and a webform, which executes a cgi-script (update_pic1.cgi)#!/bin/bash
echo "Content-type: text/html"
echo ""
sleep 2
gnuplot plot_pic.gp
echo "<html><body>"
echo "<script>location.href='///localhost/index1.html'</script>"
echo "</body></html>"
which creates a new gif image (by gnuplot).I have a well-know problem: instead o reloading the gif-image only, I have to reload the whole page since cgi script leaves the original page, which is not desired.
To circumvent this problem, I split the webpage (index2.html) into 2 frames
<html>
<frameset rows="90%,*">
<frame src="main.html">
<frame src="hidden.html" name="hidden">
</frameset>
</html>
the one with the pic and the webform (main.html)<html>
<head><script>
function updatePic(){
var pic=document.getElementById("pic");
pic.src="pic.gif"
}
</script></head>
<body>
<img src="pic.gif" id="pic">
<form action="../cgi-bin/update_pic2.cgi" method="get" target="hidden" onclick="return updatePic()">
<input type=submit value="Update Pic">
</form>
</body>
</html>
and the other one for redirecting the cgi output (hidden.html)<html>
<body>
</body>
</html>
which can be hidden.This way I don't have to reload the whole main.html, but just reload the picture only by using onclick javascript function.
The problem is that in this case the javscript function does not wait for the script creating the new pic.gif and redraws the old gif image.
How to force pic.gif on main.html to be renewed only after it is created by the cgi-script, and not before?
I would appreciate a solution without references to Perl and AJAX and not longer than 5 lines of code. Bash, javascript or c++ are preferred. I strongly believe that a simple solution exists.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
pic.src="pic.gif"
will not recreate the image, just fetch the already created one.
will not recreate the image, just fetch the already created one.
ASKER