Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

cynricng

macrumors newbie
Original poster
Aug 24, 2012
3
0
Hi,

I am currently working on something that needs a Unix Executable file that launches apps, however I want it to take in the location of the app as an argument and launch it, so I can launch different apps with the same Unix Executable file.

I heard that it can be done with applescript, but actually I'm trying to call it from an Adobe AIR program through native process, which doesn't seem to let me open .app or applescipt programs (Not entirely sure about this, I just assumed its the case since I couldn't get it to work), therefore I got to do it with an Unix Executable file.


Thank you,
Cynric
 
Thanks.

Sorry for not being precise, actually the part that I'm stuck is how to pass arguments into the file.

I apologize if the questions sound really dumb, I have no experience with Unix at all.



Actually I tried out the example of calling TinkerProxy's Unix Exec file with arguments, so basically I'm trying to do the same thing, but TinkerProxy's file is not open source, I haven't been able to figure out how its done on the Unix's side.

http://www.mikechambers.com/blog/2010/08/04/getting-started-with-flash-and-arduino/
 
I'm not familiar with how AIR launches external commands, so please post how that happens now. For example, if the goal was to run the ping or ls command, what would that look like in AIR?

If you don't know, then you need to find that out first. Because if you don't know how to run a Unix Executable in the first place, then making one won't really solve anything.

Also, which OS version are you using? Which AIR version?
 
Sorry for the late reply, got sick for a few days.

I managed to have it work after some trial and error, here is the code if anyone is interested.


Shell script:

#!/bin/sh
APP_ADDRESS="$1"
open $APP_ADDRESS


AS3:

if (!File.desktopDirectory.resolvePath(targetName).exists){
throw new Error("App source files \"" + targetName + "cannot be found in desktop directory (Included Files)");
} else {
targetApplication = File.desktopDirectory.resolvePath(targetName);
}
var targetProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
var processArguments:Vector.<String> = new Vector.<String>();
processArguments[0] = "/Users/dp02/test2.mov";
targetProcessStartupInfo.arguments = processArguments;
targetProcessStartupInfo.executable = targetApplication;
targetProcess = new NativeProcess();
targetProcess.start(targetProcessStartupInfo);
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.