Skip navigation
Currently Being Moderated

native process execution problem in mac os

May 7, 2012 1:11 AM

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.bytesAvai lable,"");       

                Alert.show("Path : " + processID );

            }

 

 

I have tried to set arguments but didn't execute......

 

Message was edited by: aswathykrishnan

 
Replies
  • Currently Being Moderated
    May 7, 2012 5:31 AM   in reply to aswathykrishnan

    Unfortunately I am at work with a PC, so I can't test on my mac.

    Where does the program stop? Does it go into the "Yes native" branch and then you get the "Error" alert? Or you get the "No" alert right away?

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 15, 2012 5:22 AM   in reply to aswathykrishnan

    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 santanu@172.25.1.22";

     

                                  npInfo.arguments = arg;

                                  process = new NativeProcess();

      process.start( npInfo );

     

     

    Can you please help?

     

    Thank you.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points