On Monday, 05 December 2011 11:19:51 Denis Spichkin wrote: > Trying to write a program for mod_perl2 that gradually display its > output such as output from "ping" (output during PIPE execution). > > For example > http://www.websitepulse.com/help/testreq.php?host=www.ya.ru&location=9&type= > 1&singletestpage=ping-test&pass=&ttref=http%3A%2F%2Fwww.websitepulse.com%2F& > __=1323068838832 > > At the moment I was able display all output at once. That completely > unacceptable for this type of program > > my $ping = '/bin/ping'; > my $count = '-c 10'; > open (PIPE, "$ping $count $param |"); > if (!<PIPE>) { > $r->print("Error: can't open the pipe $!"); > return OK; > }; > > while (<PIPE>) { > $r->write($_); # tried $r->print and $r->puts......with > the same result > $r->write('<br />'); > }; > > close (PIPE); > > > Please if anyone know how possible gradually display output in > mod_perl2 help me........
I believe your program works as expected. The rest is a browser issue. Try this one on the command line: perl -MIO::Socket::INET -le ' my $s=IO::Socket::INET->new($ARGV[0].":80"); $s->print("GET $ARGV[1] HTTP/1.0\r\nHost: $ARGV[0]\r\n\r\n"); while(<$s>) { print time."\t".$_; }' www.websitepulse.com '/help/testreq.php?host=www.ya.ru&location=9&type=1&singletestpage=ping- test&pass=&ttref=http%3A%2F%2Fwww.websitepulse.com%2F&__=1323068838832' Here I get the output: 1323076533 HTTP/1.1 200 OK ... 1323076533 </b></td></tr><tr bgcolor=#F5F5F5><td nowrap>64 bytes from www.yandex.ru (77.88.21.3): icmp_seq=0 ttl=56 time=158 ms 1323076534 </td></tr><tr bgcolor=#F5F5F5><td nowrap>64 bytes from www.yandex.ru (77.88.21.3): icmp_seq=1 ttl=56 time=158 ms 1323076535 </td></tr><tr bgcolor=#F5F5F5><td nowrap>64 bytes from www.yandex.ru (77.88.21.3): icmp_seq=2 ttl=56 time=158 ms 1323076536 </td></tr><tr bgcolor=#F5F5F5><td nowrap>64 bytes from www.yandex.ru (77.88.21.3): icmp_seq=3 ttl=56 time=158 ms 1323076537 </td></tr><tr bgcolor=#F5F5F5><td nowrap>64 bytes from www.yandex.ru (77.88.21.3): icmp_seq=4 ttl=56 time=158 ms 1323076537 </td></tr><tr bgcolor=#F5F5F5><td nowrap> You see the first few lines come in at the same time. Then between each of the ping output lines is an interval of 1 sec. The reason why you don't see it immediately in the browser window is the browser rendering. Have a look also at: http://foertsch.name/ModPerl-Tricks/ServerPush.shtml http://foertsch.name/ModPerl-Tricks/req-hand-over.shtml Torsten Förtsch -- Need professional modperl support? Hire me! (http://foertsch.name) Like fantasy? http://kabatinte.net