Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

CGI Buffer problem after upload with multipart form

by ultibuzz (Monk)
on Jun 13, 2007 at 12:34 UTC ( [id://620936]=perlquestion: print w/replies, xml ) Need Help??

ultibuzz has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,
i'm having problems with bufferoutputs after i upload something with a multipartform.

basicly i launch background scripts with a system(1,cmd,arg), so i don't need to mess with threads or fork, and i don't need to monitor the launched script.
here is a SUB where i'm launching a background script and everything works well
The Sub (code reduced)

my $sth_cs = $dbh->prepare(q~update script_run_rules s +et running=1,run_user=? where NAME='InvDispute'~) or die "Couldn't pr +epare statement: " . $dbh->errstr; $sth_cs->execute($u_email); my @args = ("c:\\Apache2.2\\script_run\\exec_invdisput +e.pl", $u_email); system( 1,$cmd, @args ); print header; print Header_HTML(); print<<HTML; <table width="745" border="0" align="center" cellpaddi +ng="0" cellspacing="0"> $balken $scr_menue <tr><td>&nbsp;</td></tr> <tr><td align="center"><p>script started you will get +an email when it's finished</p></td></tr> $logo </table></body></HTML> HTML
and this is the background script (code reduced)
my $sth = $dbh_o->prepare(q~GIANT MIGHTY SQL STATEMENT~) or die "Couldn't prepare statement: " . $dbh_o->errstr; open(OUT,'>',"c:\\Apache2.2\\script_run\\Calldetails_".$inv_nr +.".txt") or die("open failed: $!"); $sth->execute($inv_nr); while (my @data = $sth->fetchrow_array()) { print OUT join(';',@data),"\n"; } $dbh_o->disconnect; close(OUT);

so system( 1,$cmd, @args ); calls the external script and the user can messaround with the site, the launched script finishes the work and send an email to the user when his output is ready.


Now some other sub with the difference of uploading a file with informations (code reduced)

binmode $filehandle; open OUT, "> c:\\Apache2.2\\script_run\\BV_on_acc.txt" + or die $!; binmode OUT; { my $buffer; while ( read $filehandle, $buffer, 1024 ) { print OUT $buffer; } } close OUT; close $filehandle; my $sth_cs = $dbh->prepare(q~update script_run_rules s +et running=1,run_user=? where NAME='BVonAcc'~) or die "Couldn't prepa +re statement: " . $dbh->errstr; $sth_cs->execute($u_email); my @args = ("c:\\Apache2.2\\script_run\\exec_bvonacc.p +l", $u_email); system( 1,$cmd, @args ); print header; print Header_HTML(); print<<HTML; <table width="745" border="0" align="center" cellpaddi +ng="0" cellspacing="0"> $balken $scr_menue <tr><td>&nbsp;</td></tr> <tr><td align="center"><p>script started you will get +an email when it's finished</p></td></tr> $logo </table></body></HTML> HTML }

and the background script (code reduced)
system('sqlldr.exe CREDS CONTROL=C:\Apache2.2\script_run\bv_on_acc_loa +der.ctl'); my $sth = $dbh_o->prepare(q~MIGHTY SQL STATEMENT~) or die "Couldn't pr +epare statement: " . $dbh_o->errstr; open(OUT,'>',"c:\\Apache2.2\\script_run\\$file") or die("open failed: +$!"); $sth->execute(); while (my @data = $sth->fetchrow_array()) { print OUT join(';',@data),"\n"; } $dbh_o->disconnect; close(OUT);

so system( 1,$cmd, @args ); launches the backgroud script.
but now the launched script pushes back the buffer output to the main CGI site,data flows during the whole time the background process runs and the site is unusable.

i checked the search about buffer CGI and apache and i found some tips, and tryed them but nothing works.
this only happens when the launching sub uses a multipartform.
i really apreciate any idear or tipp how to solve this

kind regards
ultibuzz

PS: i hope the readmore's are working

Replies are listed 'Best First'.
Re: CGI Buffer problem after upload with multipart form
by ultibuzz (Monk) on Jun 13, 2007 at 14:07 UTC

    well problem solved :)
    problem was the sqlldr that forces itself a print to STDOUT, wich the CGI also listen on, during the upload of the file from multipart form.

    i replaced the background scripts system with my @garbage=qx{sqlldr.exe MOP CONTROL=C:/Apache2.2/script_run/bv_on_acc_loader.ctl};
    so all output is foreced to come back to the @garbage array.

    it's propably not the nicesed way to handly it, but i found so far no other ;)
    thx to all of u thinking about my problem

    kd ultibuzz

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://620936]
Approved by Joost
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-18 19:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found