2 Replies Latest reply on Mar 1, 2010 11:51 AM by Vejko

    Trimmed standard output using NativeProcess

    Vejko Level 1

      Hi,

       

      I would like to list all the USB devices connected to the machine (OSX snow leopard) and I am using NativeProcess in AIR 2.0.

       

      It works perfectly, but the result XML is trimmed. It looks I only get the first part of the standard output data.

       

      does anyone have an idea what can be the problem?

       

      This is my code:

       

      //-------------------------------------------------------------

       

      public function getUSBDevices():void

       

      {         

       

        var file:File = file.resolvePath("/usr/sbin/system_profiler");                  

       

        var args:Vector.<String> = new Vector.<String>;              
                                               
        args.push("system_profiler");  
        args.push("SPUSBDataType");              
        args.push("-xml");              
       
        var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
        nativeProcessStartupInfo.arguments =  args;
        nativeProcessStartupInfo.executable = file;
       
        process = new NativeProcess();              
       
        process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA,        onOutputData)                  
        process.addEventListener(NativeProcessExitEvent.EXIT,                                 onExit);
       
        process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA,          onIOError);
        process.addEventListener(IOErrorEvent.STANDARD_OUTPUT_IO_ERROR, onIOError);
        process.addEventListener(IOErrorEvent.STANDARD_ERROR_IO_ERROR,   onIOError);
        process.addEventListener(IOErrorEvent.STANDARD_INPUT_IO_ERROR,     onIOError);
       
        process.start(nativeProcessStartupInfo); 
       
        } 
       
        //-------------------------------------------------------------
       
        public function onExit(e:NativeProcessExitEvent):void{
       
        textReceived.text = String(res);        
       
        }          
       
        //-------------------------------------------------------------
       
        public function onOutputData(event:ProgressEvent):void {         
       
        res = process.standardOutput.readUTFBytes(process.standardOutput.bytesAvailable);
        } 
       
        //-------------------------------------------------------------

       

      If I call system_profiler SPUSBDataType -xml through the OSX terminal I get a full XML result, but from my AIR app I only get the half of it.

       

      Thanks in advance,

          Zsolt