[Mono-dev] excute linux command under mono C#

Michael Hutchinson m.j.hutchinson at gmail.com
Tue Jun 10 18:27:11 EDT 2008


On Tue, Jun 10, 2008 at 6:21 PM, Alan_Chun <kokolee88 at hotmail.com> wrote:
>
> Hi, any one know how to execute a command, e.g, "stty 9600 -F /dev/ttyS0"
> under mono C#?
>
> string cmd = "stty 9600 -F /dev/ttyS0" ;
> System.Diagnostics.Process proc = new System.Diagnostics.Process();
> proc.StartInfo.FileName = ???   //here
> proc.StartInfo.Arguments = cmd; ////??????
> proc.StartInfo.UseShellExecute = false; ///????
> proc.StartInfo.RedirectStandardOutput = true;
> proc.Start();

Pass your shell command to a shell such as sh or bash:

Filename: "sh" (or "bash")
Arguments: "-c ' " + your_escaped_command + " ' "

-- 
Michael Hutchinson
http://mjhutchinson.com


More information about the Mono-devel-list mailing list