Re: [webmin-devel] Writing CGI Output Immediately without buffer
"Tan Rezaei" <[email protected]>
| Newsgroups | gmane.comp.web.webmin.devel |
|---|---|
| Message-ID | <[email protected]> |
Sorry for beating this to death but I am still not getting the desired
effect. I have the following code:
#!/usr/bin/perl
#perform_copy.pl
require './tanmodule-lib.pl';
$|=1;
&ui_print_unbuffered_header("Copy Productlines","");
&ReadParse();
$pdline_from=$in{'pdline_from'};
$pdline_to=$in{'pdline_to'};
$copy_struct=$in{'copy_struct'};
$copy_code=$in{'copy_code'};
$copy_data=$in{'copy_data'};
$timestamp=¤tdate();
print "Copying from the <b> $pdline_from </b> Productline to the
<b>$pdline_to</b> Productline <p>\n";
print "Copying:<p>\n";
if ($copy_struct == 1) {
print "<li> Structure</li>";
}
if ($copy_code == 1) {
print "<li> Source Code</li>";
}
if ($copy_data == 1) {
print "<li> Data</li>";
}
if ($copy_struct == 1) {
print "<p><p> Dumping System Definitions from $pdline_from<p>\n";
print "using command: sysdump $pdline_from /tmp/$pdline_from<p>\n";
$sysdumpfile=$config{'BACKUPDIR'}."/".$pdline_from."_".$timestamp.'.sysdump';
$rc=&sysdump($pdline_from,$sysdumpfile);
if ($rc != 0) {
print "There was an error with the sysdump process, check your system and
try again\n";
print "<hr>\n";
&footer("", $text{'index_return'});
exit 1;
}
print "sysdump complete successfully!<p>\n";
$dmpprodmenusfile=$config{'BACKUPDIR'}."/".$pdline_from."_".$timestamp.'.menudump';
print "<p><p> Dumping System Menu Definitions from $pdline_from<p>\n";
print "using command: dmpprodmenus $pdline_from /tmp/$pdline_from<p>\n";
$rc=&dmpprodmenus($pdline_from,$dmpprodmenusfile);
if ($rc != 0) {
print "There was an error with the menu dump process, check your system
and try again<p>\n";
print "$0<p>\n";
print "<hr>\n";
&footer("", $text{'index_return'});
exit 1;
}
print "sysdump complete successfully!<p>\n";
#sysload -efp {dumpfile 1} {NewPLName}
#ldprodmenus {dumpfile 2} {NewPLName}
}
_____________________________________________________
and in my tanmodule-lib.pl file I have the functions called above defined
as:
sub sysdump {
$rc=`$GENDIR/bin/sysdump $_[0] $_[1] > /dev/null \&`;
$PID=&getpid('sysdump');
print "processing sysdump, please wait .";
while ($PID > 0) {
print '.';
sleep 3;
$PID=&getpid('sysdump');
}
print "<p>\n";
return $rc;
}
sub dmpprodmenus {
$rc=`$GENDIR/bin/dmpprodmenus $_[0] $_[1] > /dev/null \&`;
$PID=&getpid('dmpprodmenus');
print "processing dmpprodmenus, please wait";
while ($PID > 0) {
print '.';
sleep 3;
$PID=&getpid('sysdump');
}
print "<p>\n";
return $rc;
}
print "<hr>\n";
&footer("", $text{'index_return'});
______________________________________________________
I still have to wait until everything is completed before I get any output.
Any ideas? Is this maybe theme dependent? I am using the xp-style theme.
Thanks again..
T
----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: Mon, 4 Apr 2005 13:57:36 +1000
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
-------------------------------------------------------
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