[Mono-list] Executing shell scripts from XSP2

Robert Jordan robertj at gmx.net
Sat Dec 8 15:58:05 EST 2007


Hey,

Danny Waite wrote:
> Hi guys,
>  
> I'm having a hard time trying to call a shell script from XSP2, it seems to work on somethings and not others.  What is the best way to do this?  I've included my code below...
>  
> System.Diagnostics.Process proc = new System.Diagnostics.Process();
> proc.StartInfo.FileName = "/sbin/commit_config";
> proc.StartInfo.Arguments = profile;
> proc.StartInfo.UseShellExecute = false;
> proc.StartInfo.RedirectStandardOutput = true;
> proc.Start();
> 
> proc.WaitForExit();
> if (verbose)
>   Console.WriteLine("result: " + proc.StandardOutput.ReadToEnd());

You must call proc.StandardOutput.ReadToEnd() before proc.WaitForExit().

Robert



More information about the Mono-list mailing list