Shell

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(New page: This is a replacement for the built-in shell command that was removed from Unity 1.6.1. To use it place Shell.js into your project and add an "import Shell;" at the top of your code. Then ...)
 
m
Line 5: Line 5:
  
 
static function shellp(filename : String, arguments : String) : Process  {
 
static function shellp(filename : String, arguments : String) : Process  {
var p = new Process();
+
    var p = new Process();
p.StartInfo.Arguments = arguments;
+
    p.StartInfo.Arguments = arguments;
 
     p.StartInfo.CreateNoWindow = true;
 
     p.StartInfo.CreateNoWindow = true;
 
     p.StartInfo.UseShellExecute = false;
 
     p.StartInfo.UseShellExecute = false;
Line 18: Line 18:
  
 
static function shell( filename : String, arguments : String) : String {
 
static function shell( filename : String, arguments : String) : String {
var p = shellp(filename, arguments);
+
    var p = shellp(filename, arguments);
 
     var output = p.StandardOutput.ReadToEnd();
 
     var output = p.StandardOutput.ReadToEnd();
 
     p.WaitForExit();
 
     p.WaitForExit();

Revision as of 18:21, 29 March 2007

This is a replacement for the built-in shell command that was removed from Unity 1.6.1. To use it place Shell.js into your project and add an "import Shell;" at the top of your code. Then use it the same way as you used the old shell function.

<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;

} </javascript>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox