Share via


how to execute a bash command in c#

Question

Tuesday, May 26, 2015 5:50 PM

I read many post, from them there is this one

"cannot put it msdn doesn't allow me"

I do the exact same thing in my code

        Process process = new System.Diagnostics.Process ();

        Process proc = new System.Diagnostics.Process ();
        proc.StartInfo.FileName = "/bin/bash";
        proc.StartInfo.Arguments = "-c \" " + command + " \"";
        proc.StartInfo.UseShellExecute = false; 
        proc.StartInfo.RedirectStandardOutput = true;
        proc.Start ();

where command = export DISPLAY=:0.0

and it goes to my catch, not working...

what do I do differently? even if I try to juste set command = "cd .." it doesn't work

All replies (2)

Tuesday, May 26, 2015 6:33 PM âś…Answered

found my answer : I was on windows, /bin/bash path is known to linux


Wednesday, May 27, 2015 4:23 AM

Glad you've made it by yourself.

We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.