我正在尝试从我的Xamarin Mac App安装HomeBrew(List of available trusted root certificates in iOS 11)。
这个过程很简单,比如:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
所以,要从我的应用程序执行它,我正在尝试使用“System.Diagnostic.Process”,如下所示:
ProcessStartInfo startinfo = new ProcessStartInfo();
startinfo.WorkingDirectory = "/usr/local";
startinfo.CreateNoWindow = false;
startinfo.WindowStyle = ProcessWindowStyle.Normal;
startinfo.FileName = "/usr/bin/ruby";
startinfo.Arguments = @" -e ""$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)""";
Process process = new Process();
process.StartInfo = startinfo;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.Start();
while (!process.StandardOutput.EndOfStream)
Console.WriteLine(process.StandardOutput.ReadLine());
process.StandardInput.WriteLine("exit");
process.WaitForExit();
Console.ReadKey();
我得到的输出是:
-e:1: `$(' is not allowed as a global variable name
如果我在终端中运行相同的操作,一切正常。 如果我尝试执行基本的操作:
ls -l
我收到一个奇怪的错误:
System.IO.IOException
Write fault on path /Users/[USER]/Projects/_git/[FOLDER]/bin/Debug/[APPNAME]/Contents/Resources/[Unknown]
怎么了?我必须执行一些“自动交互”,所以我需要运行这样的简单命令。我还需要其他“容量”吗?