[Webdev] continuous output...
Philip Reynolds
phil at redbrick.dcu.ie
Wed Nov 15 16:01:12 GMT 2000
Dave Wilson's [dave.wilson at heanet.ie] 22 lines of wisdom included:
:>> I'm trying to write a CGI or something that'll output something
:>> continuous. As a tester, something like:
:>
:>I'm going purely from memory here, so I may be misleading you, but ISTR that
:>in Apache it sufficed to rename your CGI script so that the name starts with
:>"nph-", and begin your output with "200 OK\nContent-type: text/html\n\n"
You can use a technique called Server push as well.
Set your content type as
multipart/x-mixed-replace
#!/bin/sh
echo "Content-type: multipart/x-mixed-replace;boundary=MyBoundaryMarker"
echo
echo "--MyBoundaryMarker"
while true
do
echo Content-type: text/html
echo
echo "<HTML><HEAD><TITLE>Date</TITLE></HEAD>"
echo "<BODY><P>The current date is: <B>"
/bin/date
echo" </B></BODY></HTML>"
echo "--MyBoundaryMarker"
sleep 10
done
----
Something like that should suffice in getting the date updated every 10
seconds. AFAIK you should be able to do the same thing with tail.
It generally used to be used for animated icons but was phased out by Java and
animated .GIF's. You can still use it[1] though.
Phil.
[1] http://www.radzone.org/tutorials/animatep.html
More information about the Webdev
mailing list