I'm using System.Diagnostics.Process.Start() to remotely launch commands on a Linux os. Until now I have been able to launch simple commands and then read the output.
For example I can execute the command echo Hello World
and read Hello World
as its output.
Here's the simplified code:
public void Execute(string file, string args) {
Process process = new Process {
StartInfo = {
FileName = file,
Arguments = args,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false
}
};
process.Start();
}
To be clearer, I use the code above like this: Execute("echo", "Hello World");
.
Here's my problem: as long as I execute simple commands everything works smooth, but I'd like to launch commands with pipes and redirects, in order to have a stronger control on the command and on its output (without handle the output itself as text).
So, is there a workaround (or maybe a specific library) to achieve this result?
Stream
class.Process.StandardOutput
- msdn.microsoft.com/en-us/library/…Process.StandardOutput
and then handle what I read, right?