2 Replies Latest reply on Sep 14, 2010 11:23 AM by raybelator

    AIR NativeProcess StandardOutput not returning all output

    DMcQ Level 1

      I'm using a simple application that can be run from the command line (on OSX) like so:

       

      oconv inFile.rad > outFile.rad

       

      When run from the command line, the output file looks like this:


      #?RADIANCE

      oconv inFile.rad

      FORMAT=Radiance_octree

       

        0.57499 0.28749 0.28749 1.55002 inFile.rad

       

      I want to package this app with my AIR 2.0 application and run via Native Process. But when I try to run this file via AIR's nativeProcess, the output of the process gets truncated somehow. All that comes in to StandardOutput is

       

      #?RADIANCE
      /Users/daniel/LBNL/COMFEN3_1/radiance/oconv scenario.rad
      FORMAT=Radiance_octree

       

        0.57499

       

      Does anybody know why AIR would truncate the data coming into StandardOutput? I wish I could use the I/O redirect character > in my arguments, but that doesn't seem to work either. I can't do this:

       

      var startupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo()
      var args:Vector.<String> = new Vector.<String>();   
      args.push("inFile.rad")
      args.push(">")
      args.push("outFile.rad")
      startupInfo.arguments = args   

       

      or this

       

      var startupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo()
      var args:Vector.<String> = new Vector.<String>();   
      args.push("inFile.rad")
      args.push(">")
      args.push("outFile.rad")
      startupInfo.arguments = args

       

      Has anybody experienced the truncation problem? Or, has anybody even gotten a I/O redirection to work via the arguments Vector?


      Thanks for any thoughts,


      Daniel 

        • 1. Re: AIR NativeProcess StandardOutput not returning all output
          DMcQ Level 1

          ...and to answer my own question. You have to read the output correctly into a ByteArray (I wasn't storing it correctly).

           

          So, your StandardOutput listener might look something like this:

           

          public function onStandardOutput(event:ProgressEvent):void
          {
            _nativeProcess.standardOutput.readBytes(_processBuffer, _processBuffer.length, _nativeProcess.standardOutput.bytesAvailable);
          }

           

          where _processBuffer is a ByteArray member of your class.

           

          However, if anybody has info on using I/O redirects in AIR, please do share.

          • 2. Re: AIR NativeProcess StandardOutput not returning all output
            raybelator

            I have a similiar problem, when using NativeProcess to run Flash Media Live Encoder command line tool (FMLEcmd) on PC (Win XP/7). FMLE starts up, sends a few lines of output, and then nothing.

            I tested on a Mac and it works correctly (continuous output from the streaming process in FMLE). For some reason on Windows the output just stops. I tested with Windows UAC on/off to see if that had anything to do with it. That didn't help.

            I even tried using the _processBuffer byteArray example above and still nothing.