问题
Is there a way to make a call to the command line, (On Debian) from ActionScript in Adobe Flash? For example, execute files:
python update.py
Steps for this on Windows would also be appreciated!
回答1:
If you are using Adobe Air version 2.0.x on Linux, you can use the NativeProcess() class (assuming your update.py is flagged as executable (a+x):
var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
var file:File = File.applicationDirectory.resolvePath("update.py");
nativeProcessStartupInfo.executable = file;
var processArgs:Vector.<String> = new Vector.<String>();
processArgs.push("AnUpdateArgument");
nativeProcessStartupInfo.arguments = processArgs;
process = new NativeProcess();
process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
process.start(nativeProcessStartupInfo);
public function onOutputData(event:ProgressEvent):void
{
var stdOut:ByteArray = process.standardOutput;
var data:String = stdOut.readUTFBytes(process.standardOutput.bytesAvailable);
trace("Got: ", data);
}
Communicating with native processes in AIR
Note: You can not do this via a browser based SWF
回答2:
OK.
I see I can substitute the value of the file variable for what ever I need executed.That's fine if I want to execute that file. What about a simple command like cd MyDir
or mkdir ThisAndThat
Just plain old passes to the shell will be great. I am also using GNU Gnash with an SFW.
来源:https://stackoverflow.com/questions/32125825/command-line-calls-in-adobe-flash