none
Parsing Command Line Output?

    Question

  • Ok so I am new to programming (still in school), so hopefully this isn't a really dumb question...

    I am working with an application at the command line level...first I figured out all the commands I need to enter for the desired actions...now I am trying to create an application in C# to "automate" these actions...so far I have figured out how to actually process my commands using the Process class (ProcessStartInfo etc). All of this is working perfectly, but now I need to do some monitoring of these actions...the commands are being run in a "verbose" mode...so my question is this...how do I parse the verbose output from my command arguments being passed in? For example, when I run a command, there is a return value of 1 "RETURN VALUE: 1". I need to parse that output to verify that the return value is 1. There is other output as well that I need to verify, that is just an example.

    I have done some searching online, but all I can find information on is parsing command line arguments...which is not what I'm trying to do.

    Any help is appreciated!

    Thanks,
    George
    Monday, November 16, 2009 4:51 PM

Answers

  • Hello, George,
    Actually, You don't need to parse the output, Could use the static overload Process.Start method http://msdn.microsoft.com/zh-cn/library/h6ak8zt5(VS.80).aspx
    public static Process Start (
        string fileName,
        string arguments
    )

    This method will return an Process object, and the Process class have a property called Process.ExitCode, this will show the result of your command execution.
    If you have anything unclear, feel free to let me know.
    Thanks
    Chao

    Wednesday, November 18, 2009 7:20 AM
    Moderator

All replies

  • So upon further research I think I have found one option...

    I can redirect Console.out to a text file and then parse the text file for the information I am looking for?

    Is that the best route to take for this problem? It seems like there should be a way to directly parse the output from the console...but perhaps not.

    Thanks for any input,

    George
    Monday, November 16, 2009 6:28 PM
  • Hello, George,
    Actually, You don't need to parse the output, Could use the static overload Process.Start method http://msdn.microsoft.com/zh-cn/library/h6ak8zt5(VS.80).aspx
    public static Process Start (
        string fileName,
        string arguments
    )

    This method will return an Process object, and the Process class have a property called Process.ExitCode, this will show the result of your command execution.
    If you have anything unclear, feel free to let me know.
    Thanks
    Chao

    Wednesday, November 18, 2009 7:20 AM
    Moderator