newbie cgi question

J

jcatron

I'm writing some bash cgi scripts and notice that the client html
screen will not update until the bash script ends. If I flood the
client with text after the html part, only the text will appear on the
client screen before script ends. How can I send html docs to client,
have them written to client screen, without the bash cgi script
ending?

Thanks
 
T

Toby A Inkster

jcatron said:
I'm writing some bash cgi scripts and notice that the client html
screen will not update until the bash script ends.

This *sounds* like a client "feature".

Do you have a URL for us to check?
 
J

jcatron

Sadly, I am working with a restricted government WAN, unaccessable
from the outside. Could be client side; it is windows xp using ie5
(I think, could be higher version of ie). I have implemented a
workaround but it's very unelegant.

Bash doesn't have an easy way to flush buffers. I might try pumping
the html into a c executable that flushes just to see what happens.

Original problem came up when parent bash spawned working script.
Parent bash tries to die but becomes defunct since child still
running; client screen unchanged until child dies and defucnt parent
finally drops out.
 
H

Hywel Jenkins

I'm writing some bash cgi scripts and notice that the client html
screen will not update until the bash script ends. If I flood the
client with text after the html part, only the text will appear on the
client screen before script ends. How can I send html docs to client,
have them written to client screen, without the bash cgi script
ending?
Can you flush stdout at certain stages in your script?
 
T

Toby A Inkster

jcatron said:
Bash doesn't have an easy way to flush buffers.

I *think* bash flushes buffers at end of line. (Similar to Perl's default
behaviour). I have tested with this CGI file (and yes, /bin/sh is a
symlink to bash):

#!/bin/sh
echo "Content-Type: text/plain"
echo ""
echo "Hello"
sleep 10
echo "World"

by telnetting into the web server and requesting the file:

GET /tobyink/test.cgi HTTP/1.1
Host: www

and it seems to print out "Hello", wait a while and then print out "World"
-- that is, it doesn't wait for the entire script to complete before
printing out "Hello".

This is why I think it must be a client "feature".

Of course, it is possible that if "sleep 10" was replaced by a more CPU
intensive statement, flushing the buffer would be given a lower priority,
so might not happen until after the next statement had executed. You may
be able to solve that with "nice" (man 1 nice)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top