GetStandardOutput() public method

public GetStandardOutput ( ) : string[]
return string[]
Beispiel #1
0
 public static string Run(ProcessStartInfo psi, WaitingForProcessToExit waitingForProcessToExit, string errorMsg)
 {
     using (Program program = new Program(psi))
     {
         program.Start();
         do
         {
             if (waitingForProcessToExit != null)
             {
                 waitingForProcessToExit(program);
             }
         }
         while (!program.WaitForExit(100));
         if (program.ExitCode != 0)
         {
             throw new CommandInvokationFailure(errorMsg, program);
         }
         StringBuilder builder = new StringBuilder("");
         foreach (string str in program.GetStandardOutput())
         {
             builder.Append(str + Environment.NewLine);
         }
         foreach (string str2 in program.GetErrorOutput())
         {
             builder.Append(str2 + Environment.NewLine);
         }
         return builder.ToString();
     }
 }
 private static string ExecuteSystemProcess(string command, string args, string workingdir, bool displayProgress, string progressTitle, string progressInfo)
 {
     if (displayProgress)
     {
         EditorUtility.DisplayCancelableProgressBar(progressTitle, progressInfo, 0.25f);
     }
     ProcessStartInfo si = new ProcessStartInfo {
         FileName = command,
         Arguments = args,
         WorkingDirectory = workingdir,
         CreateNoWindow = true,
         UseShellExecute = true
     };
     Program program = new Program(si);
     program.Start();
     while (!program.WaitForExit(100))
     {
     }
     string str = StringConcat(program.GetStandardOutput()) + StringConcat(program.GetErrorOutput());
     program.Dispose();
     UnityEngine.Debug.Log(command + " " + args + "\n" + str);
     if (displayProgress)
     {
         EditorUtility.ClearProgressBar();
     }
     return str;
 }
    private void RunProgram(ProcessStartInfo startInfo)
    {
        using (var program = new UnityEditor.Utils.Program(startInfo))
        {
            program.Start();

            while (!program.WaitForExit(100))
            {
            }

            var output         = string.Empty;
            var standardOutput = program.GetStandardOutput();
            if (standardOutput.Length > 0)
            {
                output = standardOutput.Aggregate((buf, s) => buf + Environment.NewLine + s);
            }

            var errorOutput = program.GetErrorOutput();
            if (errorOutput.Length > 0)
            {
                output += errorOutput.Aggregate((buf, s) => buf + Environment.NewLine + s);
            }

            if (program.ExitCode != 0)
            {
                UnityEngine.Debug.LogError("Failed running " + startInfo.FileName + " " + startInfo.Arguments + "\n\n" + output);

                throw new Exception("IL2CPP compile failed.");
            }
        }
    }
 private string RunCommand(string command, string arguments)
 {
     try
     {
         ProcessStartInfo si = new ProcessStartInfo(command) {
             Arguments = arguments
         };
         Program program = new Program(si);
         program.Start();
         program.WaitForExit();
         if (program.ExitCode < 0)
         {
             return null;
         }
         StringBuilder builder = new StringBuilder();
         foreach (string str2 in program.GetStandardOutput())
         {
             builder.AppendLine(str2);
         }
         return builder.ToString().TrimEnd(Environment.NewLine.ToCharArray());
     }
     catch (Win32Exception)
     {
         return null;
     }
 }