views:

148

answers:

1

My application needs to:

  1. Run an external command-line application
  2. Capture the standard output/error during execution
  3. Parse the data from the output/error and use it for status display in the main app

While it's not hard to do it, it seems to me it's a very common task, and I was wondering if there's a library or framework simplifying this task in C#.

Edit: Here's a "Mono.Options inspired" example of the kind of thing I'm looking for:

ProcessWithParser proc= new ProcessWithParser(filename, arguments);
proc.AddWatch("percent=??", v => this.percent = Convert.ToInt32(v));
proc.Start();

In the "concept" above, it would locate "percent=" in the output, read the next two characters as a string, and call the delegate using this string as a parameter.

A: 

The base class library provides the tools for this already - there isn't much a framework would really need to add to it.

Redirection of the process standard input and output streams is trivial. RegEx and using streams makes parsing this fairly easy, as well.

The framework pretty much does what any (flexible) custom library would normally do in other languages.

Reed Copsey
Ended up writing my own code to suit my needs, but since I can't release it on the web I'm accepting this answer as the "best option available for the general public".
Badaro