Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Output from external command under Win2K

Reply
Thread Tools

Output from external command under Win2K

 
 
Neil Palmer
Guest
Posts: n/a
 
      09-04-2003
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
 
Reply With Quote
 
 
 
 
James Willmore
Guest
Posts: n/a
 
      09-04-2003
On 4 Sep 2003 07:33:15 -0700
http://www.velocityreviews.com/forums/(E-Mail Removed) (Neil Palmer) wrote:
<snip>
> 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
--
Jim
---
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
---
a real quote ...
Linus Torvalids: "They are somking crack ...."
(http://www.eweek.com/article2/0,3959,1227150,00.asp)
---
a fortune quote ...
Illinois isn't exactly the land that God forgot -- it's more like
the land He's trying to ignore.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing ARGV[n] under SciTE fails; no problem under Command Window Richard Ruby 4 01-25-2007 05:58 PM
win98 on c:, win2k on d: boot.ini only shows win2k thing NZ Computing 3 08-15-2004 06:47 PM
Capture external command output line by line on Windows 98, shell problem. Dib Urim Perl Misc 4 12-03-2003 07:57 PM
Capture external command output line by line on Windows 98 Dib Urim Perl Misc 4 11-23-2003 12:14 PM
LogonUser() Works Under NT4.0, Fails Under Win2K Mike ASP General 6 11-13-2003 09:13 PM



Advertisments