Output from external command under Win2K

N

Neil Palmer

I'm working on a script that makes a call to an external program that
produces a bunch of postscript and PDF files. The external program
normally issues a bunch of informational messages to STDOUT, and I
want to capture them and display them from the script. That should be
easily enough done:

#!c:/perl/bin/perl.exe -w

$| = 1;
my $execute = 'C:/Progra~1/Appdir/app.exe';
my $param1 = '-ID=customerID';
my $param2 = '-format=formattingcodes';
my $command = "$execute $param1 $param2";

open (PIPE, "$command |") || die "Cannot pipe command\n";
while (my $line = <PIPE>) {
print "$line\n";
}
close(PIPE);

#process newly created PS and PDF here

However, depending on what exactly we're producing from a given run,
the external command can take up to an hour to run. And from what
I've seen, the output doesn't get sent to the screen until the command
has finished running.

What I want to do is have any output that the external app might
produce be displayed as it is produced, rather than be held until
everything is finished, to serve as a visual feedback that the script
is in fact running as it should. I don't care about STDERR, only
STDOUT.

Any suggestions? Any other information I can provide?

ActiveState perl v5.6.1, build 631, running under Win2K
 
J

James Willmore

On 4 Sep 2003 07:33:15 -0700
What I want to do is have any output that the external app might
produce be displayed as it is produced, rather than be held until
everything is finished, to serve as a visual feedback that the
script is in fact running as it should. I don't care about STDERR,
only STDOUT.

Any suggestions? Any other information I can provide?

ActiveState perl v5.6.1, build 631, running under Win2K

Try using IPC::Open2 or IPC::Open3. The documentation has some pretty
clear examples.
You could also use Google and search for 'ipc' or 'pipe'or 'error'
for more examples. I know there's a thread out there, because I asked
something similar some time back :) Last, but not least, try
searching for 'Benjamin Goldberg'. The man has answered quite a few
questions of this type on this news group - he the man!

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top