process and exit to new page

File1 --> into shell file for processing --> file2

I have finished the work on my shell processing script, but I need to call this from a form -->cgi-bin, have the form wait/process bar while processing occurs (5-10 seconds) and then have the shell exit gracefully while transferring to the new file (file2).

:wall:

I'm not visualizing the steps to display a waiting screen tot he user and then having the shell script close while transfer to file2 display

any suggestions on the scripting\concept for this appreciated.

Brad

Here's a very simple and cheesy cgi progress bar:

#!/bin/bash

echo "Content-type: text/html"
echo
echo "<html><body><pre>Processing file:"

# Remember, you can't UN-print anything in HTML.  So it's either a very
# primitive progressbar like this, or printing entire javascript
# statements to update some fancy DHTML widget.
printf "Begin [[ "

for((N=0; N<5; N++))
do
        printf "."
        sleep 1
done

printf " ]] Done!\n</pre>\n";


cat <<EOF

<!--    URL can point to anything you want.  I just made it a data URL
        to keep the script completely self-contained.
        /etc/issue was just a handy textfile :D -->
<a id="dataurl" href="data:text/plain;base64,$(openssl base64 < /etc/issue)">Click Here Or Wait</a>
<!--    Javascript portion is necessary, since there's no other way to
        inform the web browser that you're sending a file after you've
        already started sending a webpage. -->
<script>
        // Send the user's browser to the URL.
        // Putting the openssl base64 ... junk in here doesn't work too well, since
        // javascript barfs on newlines in strings, but ordinary HTML tag attributes don't.
        e=document.getElementById("dataurl");
        window.location=e.href;
</script>
</body></html>
EOF