I’m trying to automate a workflow that uses an executable.
In terminal, I would type this:
User$ cd /Library/Application\ Support/TheApp/
And then I would do:
User$ ./UnixApp getMD /dev/2
And the terminal would give me info about /dev/2
So…
I have tried to do this seven ways to Sunday…
set x to (do shell script "cd /Library/Application Support/TheApp/; ./UnixApp getMD /dev/2" with administrator privileges)
display dialog x
I also tried…
set x to (do shell script "/Library/Application Support/TheApp/UnixApp getMD /dev/2" with administrator privileges)
display dialog x
Most times I get an error that says the file or directory can’t be found.
I guess the big issue is how can you get into the directory of the executable so that it can be used in the do shell script?
Is there a way to do this?
OK, so I figured out the path aspect of it. It works with some applications good now.
Now I hit a second issue on one application.
You need to have Compressor (part of Final Cut Pro) installed to test this script.
set x to (quoted form of POSIX path of ((path to applications folder as Unicode text) & "Compressor.app:Contents:MacOS:"))
set y to (do shell script x & "Compressor -show")
display dialog y
This command looks for available compressor clusters. At minimum it will also return “This Computer”.
If you do this in the terminal:
User$ ./Compressor -show
It would show you a list of clusters.
But when I do the Do Shell Script, the script works for like 2 minutes and then comes up with nul.
Any ideas to get this to work?
This is what the event log says:
path to applications folder as Unicode text
"MacBookPro:Applications:"
do shell script "'/Applications/Compressor.app/Contents/MacOS/'Compressor -show"
""
display dialog ""
One of these things is not like the others.
Try something like this:
do shell script "cd " & quoted form of "/Library/Application Support/TheApp/" & "; ./UnixApp /dev/2" with administrator privileges
POSIX path of ((path to application support folder as Unicode text) & "TheApp:")
do shell script "cd " & quoted form of result & "; ./UnixApp /dev/2" with administrator privileges
POSIX path of ((path to application support folder as Unicode text) & "TheApp:UnixApp")
do shell script quoted form of result & " /dev/2" with administrator privileges
See also: Technical Note TN2065: do shell script in AppleScript (Specifically, “POSIX path doesn’t work right if the file has certain characters in its name ” spaces, parentheses, $, *, etc.”)
Tangentially related: http://www.red-sweater.com/blog/78/grr-izon