SHELL-Script in Javascript
import System.Diagnostics;
static function shellp(filename : String, arguments : String) : Process {
var p = new Process();
p.StartInfo.Arguments = arguments;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.FileName = filename;
p.Start();
return p;
}
static function shell( filename : String, arguments : String) : String {
var p = shellp(filename, arguments);
var output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
return output;
}
Dazu ist ein zweites Notwendig
#pragma strict
@script ExecuteInEditMode() // um die GUI auch beim Editieren zu sehen
import Shell;
var output_of_ls;
function OnGUI ()
{
{
GUI.color = Color.yellow;
}
if (GUI.Button (Rect (10,50,150,50), "öffne mein File"))
// hier an den Namen .txt nicht vergessen
output_of_ls = shell("open", "Assets/meinFile.txt");
if (GUI.Button (Rect (10,100,150,50), "öffne PD-File"))
// hier an den Namen .pd nicht vergessen
output_of_ls = shell("open", "Assets/StreamingAssets/oscControlNachbauTutorial_copy.pd");
if (GUI.Button (Rect (160,100,150,50), "schließe PD-File"))
//Name
des Programms als zweites
Argument
output_of_ls = shell("killall", "pd"); // funktioniert!!
}