Need help with Path, shell script, POSIX path, etc.

I’m banging my head against a desk on this one. This few simple lines of code are what I need to execute a simple command line executable. The executable is a part of my application I’m building so it is included in the Resources folder. I need to obtain the path to the executable, and then run it. Can someone please give me the correct ApplescriptObjC code to do this?

set myPath to (current application's NSBundle's mainBundle()'s bundlePath()'s stringByAppendingPathComponent_("Resources")) as alias
set myPath2 to (quoted form of POSIX path of imagerPath)
set myResult to (do shell script (imagerPath2) & "/myExecutable /Users/rkubasiak/Desktop/outputfile.txt")

Thanks much.

Try:

set myPath to (current application’s NSBundle’s mainBundle()'s pathForResource_ofType_(“myExecutable”, “”)
set myResult to (do shell script (quoted form of myPath) & " /Users/rkubasiak/Desktop/outputfile.txt")

Thanks for the reply.

I posted earlier that this didn’t work, and I found a typo. This indeed gets the path to the executable, and I can show that thru a Display Dialog. I am still having the same issue at the “do shell script” though. It won’t fire. It seems like the “quoted form” isn’t applying. I’ll keep looking to see if my logic is bad or a typo is in there, but I am at the same point as my other statement.

When I display the value for my old statement, it would show the path to the Resource folder just fine, but it wasn’t quoted form so it would fail at the “do shell script” line.

Again, thanks for the help!

So, I think I’m on to something here.

First, I went into the Resources directory of the app itself and found that the executable I am including is not marked as “executable” (744), yet it is marked that way on the executable that I copied in. Interesting. I did the ‘chmod’ to it, but it still had no effect.

Next, I’m not sure if this has any effect, but do command line executable run from that location with other special permissions? I’m thinking I might need to look at permissions, and not my code! I might have been banging my head on the desk over the wrong thing all along.

Second update:

I put in a line to simply get information from the executable, rather than run it.

set temp to (do shell script "/Developer/Tools/GetFileInfo " & quoted form of myappPath)
display dialog temp

It doesn’t display anything.

If I put in a hard coded line like this:

set temp to (do shell script "/Developer/Tools/GetFileInfo /bin/ls")
display dialog temp

It works perfectly and the dialog box displays the information. I have tried throwing in “posix path of” and it doesn’t help. I am stumped!

I GOT IT!

I knew it would be simple. I always get headaches on silly things. Here is what coerced it in the end:

set myPath to (current application's NSBundle's mainBundle()'s pathForResource_ofType_("myExecutable", "") as string
set myResult to (do shell script (quoted form of myPath) & " /Users/rkubasiak/Desktop/outputfile.txt")

Adding the “as string” to the first line was the trick! Hope this helps someone else when searching.