For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > February 2006 > flush buffer problem?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author flush buffer problem?
Jim Isaacson

2006-02-08, 8:53 am

Hi

I have a cgi script which writes to a tape and another which lists a scsi
tape. On the local machine when I click the submit button on the html page
to call the cgi script it displays the html code from the cgi script and
then lists the tape, on any other machine when I click submit, it stays on
the html form until enough data is received and then displays the cgi page
html.

I have tried setting the autofluse using $| = 1 and using various modules to
no avail. Since it works fine on the local Linux machine which has the web
server but not on any other machine is it something other than the flush
buffer? Is it a socket buffer?

Here is one of the cgi scripts. Any help is appreciated.

Jim

#!/usr/bin/perl

use FileHandle;

require "cgi-lib.pl";

&ReadParse(*in);

STDOUT->autoflush(1);

$file = $in{'file'};

$failed = 0;

$LOG = "/usr/local/apache2/htdocs/logs/tapelog.log";

print &PrintHeader;

print <<EOF;

<H1><CENTER>Writing file Tape</CENTER></H1>

EOF

print "<HTML><BODY>";

print "<h2>";

print "Writing $file tape now...Please Wait for Tape Complete Message<br>";

print "This can take up to 40 minutes...<br><br>";

print "</h2>";

print "<h3>";

print "<PRE>";

if(open(PIPE, "/usr/local/bin/wtape -t devst0 $file 2>/tmp/tapewrite |")) {

while(<PIPE> ) {

print "$_";

}

}

if(-s "/tmp/tapewrite") {

$failed = 1;

$status = "Failed";

unlink("/tmp/tapewrite");

}

else {

$status = "Successful";

}

$date = `date '+%m/%d/%y %H:%M:%S'`;

chomp($date);

open(LOG, ">>$LOG") || die "Unable to open $LOG file\n";

print LOG "$date|$file|$status\n";

close(LOG);

print "</h3>";

print "<br>";

print "<br>";

print "<h2>";

if($failed) {

print "Write of $file tape Failed<br><br>";

}

else {

print "Write of $file tape complete<br><br>";

}

print "<A HREF=\"/index.html\">Return to Main Tape Page </A>";

print "</h2>";

print "</html></body>";


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com