[Mono-osx] Running a shell script using System.Diagnostics.Process

Matthew Brindley mattbrindley at googlemail.com
Fri Apr 4 20:57:47 EDT 2008

On 5 Apr 2008, at 07:01, Billy Schoenberg wrote:
> On windows I have used the System.Diagnostics.Process Object, not  
> the static Start() method, but one of the instance methods (i need  
> to set some of the Properties first), when I try this on OSX no  
> luck, nothing really happens at all.

Hi Billy,

Sorry if you've already done this, but just to be sure: Your process'  
fileName should be "/bin/sh" and your first arg is the .sh file you  
want to run (because you're outside of bash).

This works for me on 10.5:

	    	using (StreamWriter shScript = File.CreateText("simple.sh"))
                 	shScript.WriteLine("echo It worked!");

             	Process shScriptProcess = new Process();
             	shScriptProcess.StartInfo = new ProcessStartInfo("/bin/ 
sh", "simple.sh");

 From terminal:

		$ mono ShDemo.exe
	 	It worked!
		$ mono -V
		Mono JIT compiler version 1.9 (tarball)
		Copyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com
		TLS:           normal
		GC:            Included Boehm (with typed GC)
		SIGSEGV:       normal
		Notification:  Thread + polling
		Architecture:  x86
		Disabled:      none



More information about the Mono-osx mailing list