Output from external command under Win2K

Discussion in 'Perl Misc' started by Neil Palmer, Sep 4, 2003.

  1. Neil Palmer

    Neil Palmer Guest

    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
     
    Neil Palmer, Sep 4, 2003
    #1
    1. Advertising

  2. On 4 Sep 2003 07:33:15 -0700
    (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.
     
    James Willmore, Sep 4, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. llama
    Replies:
    0
    Views:
    976
    llama
    Jul 23, 2003
  2. Alexander Stojakovic

    Integrated Security under Win2K and WinXP

    Alexander Stojakovic, Jan 15, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    328
    Alexander Stojakovic
    Jan 15, 2004
  3. Steve Zatz
    Replies:
    0
    Views:
    473
    Steve Zatz
    Oct 25, 2003
  4. Mike
    Replies:
    6
    Views:
    213
  5. Richard
    Replies:
    4
    Views:
    160
    Richard
    Jan 25, 2007
Loading...

Share This Page