[Mono-list] System.Diagnostics.Process.StartInfo.Arguments

Chris Howie cdhowie at gmail.com
Tue Sep 1 10:58:30 EDT 2009

On Tue, Sep 1, 2009 at 10:52 AM, Pat55<fpatterson at novell.com> wrote:
> I am trying to start a bash script using the Process class.
> The arguments is not working. The script run, but I want to be able to
> redirect the standard output to a file.
> Here is the code:
> System.Diagnostics.Process export = new System.Diagnostics.Process();
> export.EnableRaisingEvents = false;
> export.StartInfo.FileName = "/tool/find.sh";
> export.StartInfo.Arguments = "1>export.log";
> export.Start();
> export.WaitForExit();
> if (0 != export.ExitCode) Console.WriteLine("Error");


export.StartInfo.FileName = "/bin/sh";
export.StartInfo.Arguments = "/tool/find.sh 1>export.log";

> The find.sh script runs just fine by itself with the argument.
> The script will run with the application, but it does not push the output to
> a file with the argument specified.

That's because you are passing the argument to find.sh, which doesn't
understand redirection.  The shell is what does redirection, so you
must run the shell explicitly.

Chris Howie

More information about the Mono-list mailing list