1

I read many post, from them there is this one

c# - Opening the terminal process and pass commands?

I do the exact same thing in my code

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, "pplicationName='/bin/bash', CommandLine='-c " cd .. "', CurrentDirectory='', Native error= The system cannot find the file specified."

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

7
  • "goes to your catch", can you tell us what the error is that you get in the catch? Specifically the type of error and the message that it contains. Commented May 26, 2015 at 18:16
  • sorry though I said it. it's now in the question Commented May 26, 2015 at 18:17
  • Where you are setting StartInfo.FileName - I notice that's a relative path not a full path. Have you tried specifying the full path to the exe just in case it's not resolving the correct path which is causing the problem? Commented May 26, 2015 at 18:20
  • Are you running this on Windows, or on Linux via Mono? Commented May 26, 2015 at 18:20
  • @Darrell that is a full path on Linux systems. Commented May 26, 2015 at 18:23

1 Answer 1

1

You should probably try setting the full path the executable.

proc.StartInfo.FileName = "C:/SOMEPATH/Bash.exe";

I'm assuming as you are specifying a relative path, it's not resolving it. Possibly because you aren't setting a working directory for the process so it's current dir and the current dir you think it has, are different.

Sign up to request clarification or add additional context in comments.

2 Comments

thanks a lot it's as you said!! however for debuggin purpose it's on windows... what is the path to bin bash on windows 7?? how can I find it?
@CherrysaHerrim there is no bash shell on Windows unless you install one. Also, there is no benefit from doing a cd command in a shell (it won't affect the running application's current working folder).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.