Re: [webmin-devel] Writing CGI Output Immediately without buffer

"Jamie Cameron" <[email protected]>
Newsgroups gmane.comp.web.webmin.devel
Message-ID <[email protected]>
You should try not putting the output into a <table>. Some browsers will only
render the complete table when it is closed, so anything you output during 
processing will not appear until the page is complete.

 - Jamie

On 4/Apr/2005 07:11 Tan Rezaei wrote ..
> hmm, that doesn't seem to work for me. I get the same exact result when
> I 
> use the &ui_print_unbuffered_header()  as I do with the &header() function.
> I'm not sure what i am doing wrong here. But if you get a chance maybe
> you 
> could take a quick look at this code; I am sure I am missing something
> here.
> 
> Thanks
> _________________________________________________________________________
> #!/usr/bin/perl
> 
> require './tanmodule-lib.pl';
> #&header($text{'Hmmmm'}, "");
> &ui_print_unbuffered_header('Hello world',"");
> $|=1;
> print "<hr>\n";
> 
> 
> &ReadParse();
> $LAWDIR=$config{'LAWDIR'};
> $prod1=$in{'prod1'};
> $prod2=$in{'prod2'};
> 
> print "<h3>Comparing source code between $prod1 and $prod2</h3><p>\n";
> 
> print "<table border>";
> $systemcodelist=$in{'systemcodelist'};
> @systemcodes=split("\0",$systemcodelist);
> foreach $system (@systemcodes) {
> 	$found1=0;
> 	print "\n<tr $cb><td><b>Processing the ".uc($system)." system 
> code</b></td></tr>\n";
> 
> 	@PDFILES1=<$LAWDIR/$prod1/${system}src/*PD>;
> 	@WSFILES1=<$LAWDIR/$prod1/${system}src/*WS>;
> 	@SCRFILES1=<$LAWDIR/$prod1/${system}src/*.scr>;
> 	@RPTFILES1=<$LAWDIR/$prod1/${system}src/*.rpt>;
> 
> 	foreach $PDFILE (@PDFILES1) {
> 		$PDFILECOMP=$PDFILE;
> 		$PDFILECOMP=~s/$prod1/$prod2/;
> 		$result=`diff $PDFILECOMP $PDFILE 2>&1`;
> 			chomp($result);
> 			if (!-e $PDFILECOMP) {
> 				$found1=1;
> 				print "<tr $cb><td><b><font color=red>$PDFILECOMP DOES NOT 
> EXISTS!!</font></b></td></tr>\n";
> 				next;
> 			}
> 			if ($result ne '') {
> 				$found1=1;
> 				print "<tr $cb><td><a 
> href=\"showcomp.cgi?file1=$PDFILECOMP&file2=$PDFILE\">$PDFILECOMP and 
> $PDFILE are different</a></td></tr>\n"
> 			}
> 	}
> 
> 	foreach $WSFILE (@WSFILES1) {
> 		$WSFILECOMP=$WSFILE;
> 		$WSFILECOMP=~s/$prod1/$prod2/;
> 		$result=`diff $WSFILECOMP $WSFILE 2>&1`;
> 			chomp($result);
> 			if (!-e $WSFILECOMP) {
> 				$found1=1;
> 				print "<tr $cb><td><b><font color=red>$WSFILECOMP DOES NOT 
> EXISTS!!</font></b></td></tr>\n";
> 				next;
> 			}
> 			if ($result ne '') {
> 				$found1=1;
> 				print "<tr $cb><td><a 
> href=\"showcomp.cgi?file1=$WSFILECOMP&file2=$WSFILE\">$WSFILECOMP and 
> $WSFILE are different</a></td></tr>\n"
> 			}
> 	}
> 
> 
> 	foreach $SCRFILE (@SCRFILES1) {
> 		$SCRFILECOMP=$SCRFILE;
> 		$SCRFILECOMP=~s/$prod1/$prod2/;
> 		$result=`diff $SCRFILECOMP $SCRFILE 2>&1`;
> 			chomp($result);
> 			if (!-e $SCRFILECOMP) {
> 				$found1=1;
> 				print "<tr $cb><td><b><font color=red>$SCRFILECOMP DOES NOT 
> EXISTS!!</font></b></td></tr>\n";
> 				next;
> 			}
> 			if ($result ne '') {
> 				$found1=1;
> 				print "<tr $cb><td><a 
> href=\"showcomp.cgi?file1=$SCRFILECOMP&file2=$SCRFILE\">$SCRFILECOMP and
> $SCRFILE are different</a></td></tr>\n"
> 			}
> 	}
> 
> 	foreach $RPTFILE (@RPTFILES1) {
> 		$RPTFILECOMP=$RPTFILE;
> 		$RPTFILECOMP=~s/$prod1/$prod2/;
> 		$result=`diff $RPTFILECOMP $RPTFILE 2>&1`;
> 			chomp($result);
> 			if (!-e $RPTFILECOMP) {
> 				$found1=1;
> 				print "<tr $cb><td><b><font color=red>$RPTFILECOMP DOES NOT 
> EXISTS!!</font></b></td></tr>\n";
> 				next;
> 			}
> 			if ($result ne '') {
> 				$found1=1;
> 				print "<tr $cb><td><a 
> href=\"showcomp.cgi?file1=$RPTFILECOMP&file2=$RPTFILE\">$RPTFILECOMP and
> $RPTFILE are different</a></td></tr>\n"
> 			}
> 	}
> 	if ($found1==0) {
> 		print "<tr $cb><td>No differences found</td></tr>\n"
> 	}
> 
> }
> print "</table>\n";
> 
> 
> if ($in{'check_pdlibs'}) {
> 	print "<HR>\n";
> 	print "<h3>Comparing PDLIB source code between $prod1 and 
> $prod2</h3><p>\n";
> 	print "<table border>\n";
> 	@PDLIBS=<$LAWDIR/$prod1/pdlib/*>;
> 	$found1=0;
> 	foreach $PDLIBFILE (@PDLIBS) {
> 		$PDLIBFILECOMP=$PDLIBFILE;
> 		$PDLIBFILECOMP=~s/$prod1/$prod2/;
> 		$result=`diff $PDLIBFILECOMP $PDLIBFILE 2>&1`;
> 			chomp($result);
> 			if (!-e $PDLIBFILECOMP) {
> 				$found1=1;
> 				print "<tr $cb><td><b><font color=red>$PDLIBFILECOMP DOES NOT 
> EXISTS!!</font></b></td></tr>\n";
> 				next;
> 			}
> 			if ($result ne '') {
> 				$found1=1;
> 				print "<tr $cb><td><a 
> href=\"showcomp.cgi?file1=$PDLIBFILECOMP&file2=$PDLIBFILE\">$PDLIBFILECOMP
> and $PDLIBFILE are different</a></td></tr>\n"
> 			}
> 	}
> 	if ($found1==0) {
> 		print "<tr $cb><td>No differences found</td></tr>\n"
> 	}
> 	print "</table>\n";
> }
> 
> 
> if ($in{'check_wslibs'}) {
> 	print "<HR>\n";
> 	print "<h3>Comparing WSLIB source code between $prod1 and 
> $prod2</h3><p>\n";
> 	print "<table border>\n";
> 	@WSLIBS=<$LAWDIR/$prod1/wslib/*>;
> 	$found1=0;
> 	foreach $WSLIBFILE (@WSLIBS) {
> 		$WSLIBFILECOMP=$WSLIBFILE;
> 		$WSLIBFILECOMP=~s/$prod1/$prod2/;
> 		$result=`diff $WSLIBFILECOMP $WSLIBFILE 2>&1`;
> 			chomp($result);
> 			if (!-e $WSLIBFILECOMP) {
> 				print "<tr $cb><td><b><font color=red>$WSLIBFILECOMP DOES NOT 
> EXISTS!!</font></b></td></tr>\n";
> 				$found1=1;
> 				next;
> 			}
> 			if ($result ne '') {
> 				$found1=1;
> 				print "<tr $cb><td><a 
> href=\"showcomp.cgi?file1=$WSLIBFILECOMP&file2=$WSLIBFILE\">$WSLIBFILECOMP
> and $WSLIBFILE are different</a></td></tr>\n"
> 			}
> 	}
> 	if ($found1==0) {
> 		print "<tr $cb><td>No differences found</td></tr>\n"
> 	}
> 	print "</table>\n";
> }
> 
> 
> 
> print "<hr>\n";
> &footer("", $text{'index_return'});
> __________________________________________________________________
> 
> 
> 
> ----Original Message Follows----
> From: "Jamie Cameron" <[email protected]>
> Reply-To: [email protected]
> To: [email protected]
> Subject: Re: [webmin-devel] Writing CGI Output Immediately without buffer
> Date: Sun, 3 Apr 2005 08:47:04 +1000
> 
> On 3/Apr/2005 05:39 Tan Rezaei wrote ..
>  >
>  > Hi all,
>  > I am sure this question has been asked many times but I can't seem to
> find
>  > the answer anywhere.
>  > I am trying to write the output of my cgi as it happens. I have a loop
>  > that
>  > runs a certain UNIX command about 1000 times and each time prints the
>  > output. Well It doesn't actually show me any of the output until its
> done
>  > so
>  > the users have to wait and wait .. Sometimes the refresh the screen
> and
>  > we
>  > all know what that will do.
>  > How does webmin handle this ? I am trying to duplicate the feel of the
>  > module download page or the fsdump module but can't seem to figure out
>  > what
>  > that code is really doing.
> 
> The best way to force output to be sent immediately to the browser is for
> your CGI to call the ui_print_unbuffered_header function instead of 
> ui_print_header.
> Or if you are not using those ui-lib.pl functions, you can use code like
> :
> 
> $| = 1;
> $theme_no_table = 1;
> &header("page header", "");
> 
>   - Jamie
> 
> 
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> -
> Forwarded by the Webmin development list at [email protected]
> To remove yourself from this list, go to
> http://lists.sourceforge.net/lists/listinfo/webadmin-devel


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
-
Forwarded by the Webmin development list at [email protected]
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.