Skip to content

Instantly share code, notes, and snippets.

@rozgo
Created August 5, 2013 22:58
Show Gist options
  • Save rozgo/6160394 to your computer and use it in GitHub Desktop.
Save rozgo/6160394 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
using System.IO;
public class ExecuteCommand : MonoBehaviour
{
void Start ()
{
//string path = Directory.GetCurrentDirectory();
string cmd = "git";
string args = "diff Assets/Ammo/CannonBall.prefab";
string result = Command(cmd, args);
Debug.Log(result);
}
public string Command (string command, string args)
{
System.Diagnostics.ProcessStartInfo procStartInfo =
new System.Diagnostics.ProcessStartInfo (command, args);
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
System.Diagnostics.Process proc = new System.Diagnostics.Process ();
proc.StartInfo = procStartInfo;
proc.Start();
string result = proc.StandardOutput.ReadToEnd();
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment