in reply to Re: Setting up 2 way pipe for a command
in thread Setting up 2 way pipe for a command

I switched to IPC::Run but has not faired any better. I keep getting a premature end error even though there is input data. Here is the relevent code segment I have now after many various iterations:
my $h=start(\@cmd,\$in,\$out,\$err); while (!eof(FILELIST)) { $thisline=readline(FILELIST); ($thisfile,$thisfilesize)=split(/\t/,$thisline +); $in="$thisfile\n"; $h->pump; while ($h->pumpable) { $h->pump; } if (length($out)>0) { putmsg($out); } $total+=$thisfilesize; $complete=sprintf("%.2f",$total/$dumpsize); putmsg("$complete%\n"); } finish $h;
In one of my iterations I avoided the premature end message however, the script simply quits on the first call of 'pump'. No error message, nothing. Does anyone one see anything obvious? Thanks.

Replies are listed 'Best First'.
Re^3: Setting up 2 way pipe for a command
by gloryhack (Deacon) on Jul 03, 2008 at 00:48 UTC
    Uh... "premature end error"? As in HTTP server error response? If this is indeed the case, try running the thing from the command line, or at least printing a text/plain header somewhere ahead of the block above.

    Maybe on that iteration that didn't puke, the application being run via IPC::Run didn't output anything?

      Thanks for the reply. Its the "process ended prematurely" error. Sorry I didn't take the time to look up the error rather than go from poor memory. Perhaps I am misunderstanding how this works but there indeed may not be any output on the first call to 'pump'. However, there is definitely input. I then try to drain any output in the 'pumpable' loop before going on to the next input string. Therefore the way I think it works this condition should never happen unless there is a bug in the 'pumpable' function. If I am misunderstanding, please correct me as that would be the solution to my problem.