Read Console Context

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • laszlo.csabi@gmail.com

    Read Console Context

    I'm trying to create an application where I can run an certain exe file
    which runs inside a console window and print the results in it. I would
    like to capture the result displayed on the console, but the actual
    stream I got back from the process is empty.
    If you guys could point me to the right direction what I'm doing wrong,
    would be great.

    My code:

    using System;
    using System.Collecti ons.Generic;
    using System.Text;
    using System.Diagnost ics;

    namespace Svnhook
    {
    class Program
    {
    static void Main(string[] args)
    {
    Process compiler = new Process();
    compiler.StartI nfo.FileName = "cmd.exe";
    compiler.StartI nfo.Arguments = @" /c svnlook changed
    c:\InetPub\svn\ repos ";
    compiler.StartI nfo.UseShellExe cute = false;
    compiler.StartI nfo.RedirectSta ndardOutput = true;
    compiler.Start( );
    string result = compiler.Standa rdOutput.ReadTo End();
    compiler.WaitFo rExit();

    }
    }
    }

    If I open a Console window and run this command manually :
    "svnlook changed c:\InetPub\svn\ repos"

    I got the following result in the Console

    "svnlook: Transaction '<null/ is not based on a revision"

    That would be the result I'd like to capture.

    If I run my code in debuging mode the result is empty, however I could
    see it in the Console window.

    So, If some could tell me where I'm failing I would appreciate it.

  • Patrick Steele

    #2
    Re: Read Console Context

    In article <1160638075.409 695.82910@c28g2 000cwb.googlegr oups.com>,
    laszlo.csabi@gm ail.com says...
    I'm trying to create an application where I can run an certain exe file
    which runs inside a console window and print the results in it. I would
    like to capture the result displayed on the console, but the actual
    stream I got back from the process is empty.
    If you guys could point me to the right direction what I'm doing wrong,
    would be great.
    >
    My code:
    >
    using System;
    using System.Collecti ons.Generic;
    using System.Text;
    using System.Diagnost ics;
    >
    namespace Svnhook
    {
    class Program
    {
    static void Main(string[] args)
    {
    Process compiler = new Process();
    compiler.StartI nfo.FileName = "cmd.exe";
    compiler.StartI nfo.Arguments = @" /c svnlook changed
    c:\InetPub\svn\ repos ";
    compiler.StartI nfo.UseShellExe cute = false;
    compiler.StartI nfo.RedirectSta ndardOutput = true;
    compiler.Start( );
    string result = compiler.Standa rdOutput.ReadTo End();
    compiler.WaitFo rExit();
    >
    }
    }
    }
    I would try getting rid of the "/c" in your command arguments. The
    FileName you want to run should be "svnlook" and the arguments should be
    "changed C"\\IntetPub\\s vn\\repos".

    --
    Patrick Steele

    Comment

    Working...