Catching Dos console output from within Java Class

Discussion in 'Java' started by IchBin, Feb 28, 2005.

  1. IchBin

    IchBin Guest

    Is it possible to not just to issue a Dos cmd from a java class but more
    importantly encapsulate the Dos output back into a buffer that java can
    use..? Not just pipe the Dos command to a dos file and then reading that
    file. I am running under Windows XP SP 2. Reason: So I could say display
    a running status of a NetStat command I want to monitor.

    Sorry just never tried it.

    --


    Thanks in Advance...
    IchBin
    __________________________________________________________________________

    'The meeting of two personalities is like the contact of two chemical
    substances: if there is any reaction, both are transformed.'
    - Carl Gustav Jung, (1875-1961), psychiatrist and psychologist
    IchBin, Feb 28, 2005
    #1
    1. Advertising

  2. IchBin

    Hugo Pragt Guest

    Yes it is :)

    Hugo

    "IchBin" <> wrote in message
    news:D...
    > Is it possible to not just to issue a Dos cmd from a java class but more
    > importantly encapsulate the Dos output back into a buffer that java can
    > use..? Not just pipe the Dos command to a dos file and then reading that
    > file. I am running under Windows XP SP 2. Reason: So I could say display
    > a running status of a NetStat command I want to monitor.
    >
    > Sorry just never tried it.
    >
    > --
    >
    >
    > Thanks in Advance...
    > IchBin
    > __________________________________________________________________________
    >
    > 'The meeting of two personalities is like the contact of two chemical
    > substances: if there is any reaction, both are transformed.'
    > - Carl Gustav Jung, (1875-1961), psychiatrist and psychologist
    Hugo Pragt, Feb 28, 2005
    #2
    1. Advertising

  3. On Mon, 28 Feb 2005 04:38:55 -0500, IchBin wrote:

    > Is it possible to not just to issue a Dos cmd from a java class but more
    > importantly encapsulate the Dos output back into a buffer that java can
    > use..? Not just pipe the Dos command to a dos file and then reading that
    > file. I am running under Windows XP SP 2. Reason: So I could say display
    > a running status of a NetStat command I want to monitor.


    Runtime.exec returns a Process-instance. Looking at the API
    of java.lang.Process will give you all the information needed
    and is more or less self-explaining.

    If the called application is writing on STDERR as well you should
    read the contents as well, because if the buffer is full, the
    called application will block.


    Regards, Lothar
    --
    Lothar Kimmeringer E-Mail:
    PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

    Always remember: The answer is forty-two, there can only be wrong
    questions!
    Lothar Kimmeringer, Feb 28, 2005
    #3
  4. IchBin

    IchBin Guest

    Lothar Kimmeringer wrote:
    > On Mon, 28 Feb 2005 04:38:55 -0500, IchBin wrote:
    >
    >
    >>Is it possible to not just to issue a Dos cmd from a java class but more
    >>importantly encapsulate the Dos output back into a buffer that java can
    >>use..? Not just pipe the Dos command to a dos file and then reading that
    >>file. I am running under Windows XP SP 2. Reason: So I could say display
    >>a running status of a NetStat command I want to monitor.

    >
    >
    > Runtime.exec returns a Process-instance. Looking at the API
    > of java.lang.Process will give you all the information needed
    > and is more or less self-explaining.
    >
    > If the called application is writing on STDERR as well you should
    > read the contents as well, because if the buffer is full, the
    > called application will block.
    >
    >
    > Regards, Lothar


    Thanks Lothar... You gave me the direction I needed.

    --


    Thanks in Advance...
    IchBin
    __________________________________________________________________________

    'The meeting of two personalities is like the contact of two chemical
    substances:
    if there is any reaction, both are transformed.'
    - Carl Gustav Jung, (1875-1961), psychiatrist and psychologist
    IchBin, Mar 2, 2005
    #4
    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. Ben Fairbank
    Replies:
    2
    Views:
    5,403
  2. Guy Robinson
    Replies:
    1
    Views:
    385
    Miki Tebeka
    Nov 30, 2003
  3. Byrom, R (Rob)

    Catching console output interactively

    Byrom, R (Rob), Apr 16, 2004, in forum: Python
    Replies:
    4
    Views:
    325
    Michael Hudson
    Apr 20, 2004
  4. Replies:
    5
    Views:
    3,414
    James Kanze
    Mar 4, 2008
  5. Johnson Scaria John

    how to clear dos console from java

    Johnson Scaria John, Jun 13, 2008, in forum: Java
    Replies:
    6
    Views:
    2,154
    RedGrittyBrick
    Jun 16, 2008
Loading...

Share This Page