I cannot get a Terminal window to open from Process.Start().
The following should execute a shell script in a new Terminal window.
using(var process=new Process())
{
process.StartInfo.FileName=“/bin/sh”;
process.StartInfo.Arguments="shell.sh;
process.StartInfo.WorkingDirectory=“path/to/working/directory”;
process.StartInfo.CreateNoWindow=false;
process.StartInfo.UseShellExecute=false;
process.StartInfo.RedirectStandardOutput=false;
process.Start();
process.WaitForExit();
process.Close();
}
This SHOULD open Terminal and run shell.sh.
Instead, it runs shell.sh silently without opening Terminal.
Yes, I could reroute the output from shell.sh back into Unity. But if I’m running something like npm install or pod install, or something like fastlane sigh where I need to enter app store credentials, running silently isn’t an option.
The ONLY way I can get Terminal to open is by using
process.StartInfo.FileName=“open”;
and ensuring that my .sh files are set to open in Terminal by default.
2 downsides to this method:
- This instance ignores the WorkingDirectory argument and defaults to my home directory.
- I cannot pass parameters into the shell script by appending onto the end of the Arguments string.
And as a result, I can’t pass in my working directory in order to cd to the appropriate location from within the shell script.
What am I missing here? Why isn’t Terminal opening when I using FileName=“/bin/sh”, and how should I pass params using FileName=“open”?