On Tue, Sep 1, 2009 at 10:52 AM, Pat55<[email protected]> 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");

Try:

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
http://www.chrishowie.com
http://en.wikipedia.org/wiki/User:Crazycomputers
_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to