1 Reply Latest reply on Mar 12, 2011 3:52 PM by DanelKirch

    NativeProcess exitCode

    DanelKirch Level 1

      im dealing here with NativeProcess and specificly with commands in OS X.

       

      So, i have a .sh file in same dir as my app (currently Flash IDE and not yet Native Installer) and im reaching for that file, seems to work fine

      BUT i keep getting response from NativeProcessExitEvent dispatcher...

       

      and the exitCode is everything between 0 - 5 .

       

      Interesting part is that ive got 3 exitcodes so far.

      0 - it seemed that nothing happend in native process

      1 - is was exited normally

      2 - ?

      3 - ?

      4 - ?

      5 - when everything goes wrong, but what goes wrong (probably spaces infront of all lines in run.sh file) ?

       

      since LanguageReference doesnt link to any page where these exitCodes are listed, i need some guidance here

       

      anyhow, here is the code i have (maybe not the best one but its a start)

      in the same dir where this FLA is, i got run.sh as well

       

      I know that im not close enough to execute .sh paramsa from AIR, so in that case if you see anything wierd or wrong, let me know.

      There isnt much to walk on when working with NativeProcesses

       

       

      import flash.desktop.NativeProcess;

      import flash.desktop.NativeProcessStartupInfo;

      import flash.events.Event;

      import flash.events.ProgressEvent;

      import flash.events.IOErrorEvent;

      import flash.events.NativeProcessExitEvent;

      import flash.filesystem.File;

      import flash.events.MouseEvent;

       

      var file:File = File.applicationDirectory.resolvePath('run.sh');

       

          

          

          

           var process:NativeProcess = new NativeProcess();

          

           var sui:NativeProcessStartupInfo = new NativeProcessStartupInfo();

          

           var args:Vector.<String> = new Vector.<String>();

           args.push('chmod -x "'+file.nativePath+'"');

           sui.executable = file;

           sui.arguments = args;

           process.addEventListener(NativeProcessExitEvent.EXIT, onExitError );

           process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onInputData);

           process.addEventListener(ProgressEvent.STANDARD_INPUT_PROGRESS, onInputData);

           process.addEventListener(IOErrorEvent.STANDARD_INPUT_IO_ERROR, onIOError);

           process.addEventListener(IOErrorEvent.IO_ERROR, onIOError);

           process.addEventListener(IOErrorEvent.STANDARD_OUTPUT_IO_ERROR, onIOError);

          

           process.start(sui);

          

          

           process.closeInput();

           //process.exit(true);

       

       

      function onInputData(p:ProgressEvent):void{

           trace('2->'+process.standardOutput.readUTFBytes(process.standardOutput.bytesAvailable)+ ' - ' + p.bytesTotal)

      }

      function onExitError(n:NativeProcessExitEvent):void

      {

           trace('exitCode ',n.exitCode);

      }

       

       

       

      and run.sh

       

       

       

      #!/bin/sh

       

      exec $@

       

       

      this particular code gives me exitCode 1, but what is it, what does it and what does it mean ? :S

        • 1. Re: NativeProcess exitCode
          DanelKirch Level 1

          UPDATE:

           

          when changing as3 to

          process.start(sui);

               if(process && process.running){

                    process.standardInput.writeUTFBytes('say hello');

               }

               process.closeInput();

          then i get this error

           

          [SWF] ShellApp.swf - 4298 bytes after decompression

          [IOErrorEvent type="standardInputIoError" bubbles=false cancelable=false eventPhase=2 text="Error #3218: Error while writing data to NativeProcess.standardInput." errorID=3218]

          exitCode  1

          [UnloadSWF] ShellApp.swf

           

          could someone explain ?