Current Position:Home > Native process execution problem in mac os

Native process execution problem in mac os

Update:10-11Source: network consolidation
Advertisement
hi,
     In my flex application i have to get mac serial  number as a unique id for each system . On searching i got one terminal command to get serial number. For that i have  run terminal command through flex native process. I have set supportedprofile as <supportedProfiles>extendedDesktop desktop</supportedProfiles> in app xml. But when i install and run application on mac terminal is getting opened but command is not executing. I couldn't trace out the problem.  I could execute cmd in windows and that worked . Please help me to findout a solution................... The test code is adding below
private var process:NativeProcess
=
new NativeProcess();
protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
                // TODO Auto-generated method stub
                if(NativeProcess.isSupported) {
                    Alert.show("Yes NativeProcess");
                    process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutput);
                    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(NativeProcessExitEvent.EXIT,onIOError);
                    var info:NativeProcessStartupInfo     =     new NativeProcessStartupInfo();
                    info.executable                               =     new File("/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal");
                     /*  var startupArgs:Vector.<String>    =     new Vector.<String>();
                         startupArgs[0]                              =    'system_profiler |grep "r (system)" '; 
                         info.arguments                              =    startupArgs;*/
                    //Alert.show(String(info.arguments.length));
                     process.start(info); 
                    process.standardInput.writeUTFBytes('system_profiler |grep "r (system)" '+ "\n");
                }else
                    Alert.show("No");
            protected function onIOError(event:IOErrorEvent):void
                // TODO Auto-generated method stub
                Alert.show("Error");
            protected function onOutput(event:ProgressEvent):void
                var processID:String            =    process.standardOutput.readMultiByte(process.standardOutput.bytesAvailable,"");       
                Alert.show("Path : " + processID );
I have tried to set arguments but didn't execute......
Message was edited by: aswathykrishnan

The Best Answer

Advertisement
Hello Aswathy, these days I'm also coding an application which uses AIR NativeProcess and I required to open the MacOS terminal with some parameter/commands. I also eventually turn to the AppleScript, but I considerably new to the AppleScript, yet trying to findout a way to passing parameters (the command argument) to the AppleScript; the appleScript I managed to open but not passing the argument. Can you please help? here's my some probable codes for the application:
My appleScript is:
#!/bin/bash
on run argv
          tell application "Terminal"
                    set currentTab to (do script) & item 1 of argv
          end tell
end run
I've packaged the appleScript as an Application (Contract.app) and here's my Flex code:
var npInfo : NativeProcessStartupInfo = new NativeProcessStartupInfo();
npInfo.executable = new File( "/Applications/Contract.app/Contents/MacOS/applet" );
                              var arg:Vector.<String> = new Vector.<String>;
                                  arg[0]="ssh [email protected]";
                              npInfo.arguments = arg;
                              process = new NativeProcess();
  process.start( npInfo );
Can you please help?
Thank you.
  • Native process execution problem in mac os Update:10-11

    hi,      In my flex application i have to get mac serial  number as a unique id for each system . On searching i got one terminal command to get serial number. For that i have  run terminal command through flex native process. I have set supportedpro

  • Problem with blocked native processes Update:10-11

    My application relies heavily on native processes so that I am trying to implement fallback strategies if a native process doesn't work as expected. While creating test scenarios I had a problem with handling errors caused directly by the start() met

  • Problem description: mac mail not opening, software updates not working, app store not opening. imac osx 10.9.5 Update:10-11

    Problem description: mac mail not opening, software updates not working, app store not opening. 10.9.5 EtreCheck version: 2.0.11 (98) Report generated 1 December 2014 16:51:49 CET Hardware Information: ℹ️   iMac (21.5-inch, Late 2009) (Verified)   iM

  • AD account Login problem with MAC 10.6.8 Update:10-11

    Hi All, We have around 50 odd MAC that are connected to windows server 2008 R2. the user were logining in to these MACs using their AD account. Recently few of the random MAC did not allow the user to login using their AD account.When analyzed though