Capture external command output line by line on Windows 98

Discussion in 'Perl Misc' started by Dib Urim, Nov 20, 2003.

  1. Dib Urim

    Dib Urim Guest

    Hello,

    I'm trying to Capture external command output and error line by line.
    I wrote this example witch work excellent on Windows 2000:

    open(PROC,"DIR 2>&1 |");
    while(<PROC>) {
    print ("LINE:$_");
    }
    close(PROC);

    But on Windows 98 it don't do nothing!
    I'm user perl 5.6.1 activestate 625.
    I need to display the output line by line and not all at once
    so I can't use system command.
    How can I implement it on windows 98 ?

    Thanks
    Dib
    Dib Urim, Nov 20, 2003
    #1
    1. Advertising

  2. Hi Dib,

    DIR is a built in to the command interperter, command.com.

    You have to do this:

    open(PROC, "command.com /c DIR |");

    Cheers,
    Ben Liddicott

    "Dib Urim" <> wrote in message
    news:bpikqt$f40$...
    > Hello,
    >
    > I'm trying to Capture external command output and error line by line.
    > I wrote this example witch work excellent on Windows 2000:
    >
    > open(PROC,"DIR 2>&1 |");
    Ben Liddicott, Nov 20, 2003
    #2
    1. Advertising

  3. Dib Urim

    Dib Urim Guest

    Hello Ben,

    Thank for you quick replay.
    What abut command/utils that are not in the command interpreter.
    Specially I need to capture the output/error of utility called rsync.exe

    Dib

    "Ben Liddicott" <> wrote in message
    news:bpimso$phl$...
    > Hi Dib,
    >
    > DIR is a built in to the command interperter, command.com.
    >
    > You have to do this:
    >
    > open(PROC, "command.com /c DIR |");
    >
    > Cheers,
    > Ben Liddicott
    >
    > "Dib Urim" <> wrote in message
    > news:bpikqt$f40$...
    > > Hello,
    > >
    > > I'm trying to Capture external command output and error line by line.
    > > I wrote this example witch work excellent on Windows 2000:
    > >
    > > open(PROC,"DIR 2>&1 |");

    >
    >
    Dib Urim, Nov 23, 2003
    #3
  4. On Thu, 20 Nov 2003 16:24:35 +0200
    "Dib Urim" <> wrote:
    > I'm trying to Capture external command output and error line by
    > line. I wrote this example witch work excellent on Windows 2000:
    >
    > open(PROC,"DIR 2>&1 |");
    > while(<PROC>) {
    > print ("LINE:$_");
    > }
    > close(PROC);
    >
    > But on Windows 98 it don't do nothing!
    > I'm user perl 5.6.1 activestate 625.
    > I need to display the output line by line and not all at once
    > so I can't use system command.
    > How can I implement it on windows 98 ?


    For an idiomatic Perl solution, type:
    perldoc -q "STDERR"

    This will produce perlfaq8, which approaches the question ...
    "How can I capture STDERR from an external command?"

    You could also use Google, using the following keywords:
    "comp.lang.perl.misc STDERR capture"

    This query gives, again, idiomatic Perl solutions. For OS specific
    solutions, use whatever command you execute at the command line in the
    system call.

    This question has been asked and answered before - so the solution is
    available to you :)

    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 fortune quote ...
    The right half of the brain controls the left half of the body.
    This means that only left handed people are in their right mind.
    James Willmore, Nov 23, 2003
    #4
  5. Hi Dib,

    I really don't know whether you can do this in Win98. Sorry.

    I suggest you try a Windows newsgroup.

    --
    Cheers,
    Ben Liddicott

    "Dib Urim" <> wrote in message news:bpq07c$dos$...
    > Hello Ben,
    >
    > Thank for you quick replay.
    > What abut command/utils that are not in the command interpreter.
    > Specially I need to capture the output/error of utility called rsync.exe
    Ben Liddicott, Nov 23, 2003
    #5
    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. Ernesto
    Replies:
    1
    Views:
    757
    Ernesto
    Feb 1, 2006
  2. Peter A. Schott
    Replies:
    4
    Views:
    582
    Peter A. Schott
    Feb 7, 2006
  3. Aditya Mahajan
    Replies:
    4
    Views:
    82
    mortee
    Oct 15, 2007
  4. Dib Urim
    Replies:
    4
    Views:
    178
    Michele Dondi
    Dec 3, 2003
  5. PerlFAQ Server
    Replies:
    0
    Views:
    285
    PerlFAQ Server
    Mar 12, 2011
Loading...

Share This Page